You are viewing a single comment's thread. Return to all comments →
I don't think you need the first "if", do you ? This is my (accepted) JS solution :
function repeatedString(s, n) { var inString = 0; var added = 0; for(var i = 0 ; i < s.length ; i++) { if(s[i] == 'a') { inString++; if(i < (n%s.length)) added++; } } var repeats = (n- n%s.length)/s.length; return repeats*inString+added; }
Repeated String
You are viewing a single comment's thread. Return to all comments →
I don't think you need the first "if", do you ? This is my (accepted) JS solution :