Skip to content

Instantly share code, notes, and snippets.

@rosdyana
Created August 30, 2019 02:09
Show Gist options
  • Save rosdyana/392c2c3940cdd51c79de57de451c3fd6 to your computer and use it in GitHub Desktop.
Save rosdyana/392c2c3940cdd51c79de57de451c3fd6 to your computer and use it in GitHub Desktop.
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