We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
count*(n/l) is needed because count only recorded the amount of times that 'a' occuranced in the oringial string (i.e not the repeated string). So we need to multiply the count by the amount of times the string was repeated.
A better way of seeing is it is count*repeats + leftover occurances
"+ count1" is needed since there could be strings with leftover 'a's, and we've already kept track of that with the second for loop
I hope this helps
Cookie support is required to access HackerRank
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 →
count = count*(n/l)+ count1 breakdown:
count*(n/l) is needed because count only recorded the amount of times that 'a' occuranced in the oringial string (i.e not the repeated string). So we need to multiply the count by the amount of times the string was repeated.
A better way of seeing is it is count*repeats + leftover occurances
"+ count1" is needed since there could be strings with leftover 'a's, and we've already kept track of that with the second for loop
I hope this helps