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
|
3645 Discussions
|
Please Login in order to post a comment
//Java 15
//Java
Java
Python 3
def repeatedString(s, n): b = int(n/len(s)) # repeated sring c = n%len(s) # leftover string x = s.count('a')*b # count a in repeated string y = s[:c].count('a') # count a in leftover string z = x +y # total a return z
Here is my c++ solution, you can watch the explanation here : https://youtu.be/Vh5davsSkfA