Created
August 30, 2019 02:09
-
-
Save rosdyana/392c2c3940cdd51c79de57de451c3fd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def repeatedString(s, n): | |
number = s.count('a') | |
if number == 0: | |
return 0 | |
if number == 1 and len(s) == 1: | |
return n | |
repeats = n//len(s) | |
remainder = math.floor(n%len(s)) | |
return number*repeats+s[:remainder].count('a') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment