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.
Think I did the same thing in a more explicit way:
defrepeatedString(s,n):length=len(s)complete=n//length# total complete stringsleft=n%lengthoccur=0# in single sequenceforidx,chinenumerate(s):if'a'==ch:occur+=1occur=occur*complete# in remainderifleft>0:foridx,chinenumerate(s):if'a'==chandidx<left:occur+=1returnoccur
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 →
Think I did the same thing in a more explicit way: