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
|
3670 Discussions
|
Please Login in order to post a comment
python solution:
def repeatedString(s, n): a = s.count('a') if a == 1 and len(s)==1: return n else: result = (n//len(s)) * a result += s[:n%len(s)].count('a') return result
Haskell:
Here is my c++ solution, you can watch the explanation here : https://youtu.be/Vh5davsSkfA