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.
Yours is the only one that passed all the test cases. Any reason why didn't make it past the 15th test?
if len(s) == 1:
if s == 'a':
return n
else:
return 0
elif len(s) in range(1, 101):
if n < (10 ** 12) + 1:
return ((s * (int(n // len(s)) + 1))[:n]).count('a')
else:
return 0
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 →
Yours is the only one that passed all the test cases. Any reason why didn't make it past the 15th test?
if len(s) == 1: if s == 'a': return n else: return 0 elif len(s) in range(1, 101): if n < (10 ** 12) + 1: return ((s * (int(n // len(s)) + 1))[:n]).count('a') else: return 0