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.
Repeated String
Repeated String
Sort by
recency
|
3717 Discussions
|
Please Login in order to post a comment
def repeatedString(s, n):
def count_a(s): count=0 for i in s: if (i=="a"): count+=1 return count
Here is my c++ solution, you can watch the explanation here : https://youtu.be/Vh5davsSkfA
Python full_repeats = n // len(s) remainder = n % len(s) a_count = s.count('a') total_a_count = full_repeats * a_count total_a_count += s[:remainder].count('a') return total_a_count `
My python3 solution