You are viewing a single comment's thread. Return to all comments →
Same concept, in JS:
function repeatedString(s, n) { const counta = (str) => str.split('') .filter(c => c == 'a') .length const d = Math.floor(n / s.length) const r = n - (s.length * d) return d * counta(s) + counta(s.substr(0, r)) }
Seems like cookies are disabled on this browser, please enable them to open this website
Repeated String
You are viewing a single comment's thread. Return to all comments →
Same concept, in JS: