You are viewing a single comment's thread. Return to all comments →
C# simple solution:
public static long repeatedString(string s, long n) { int countInSingleString = s.Count(c=>c == 'a'); var quotient = n/s.Length; var remainder = n%s.Length; var aCnt = countInSingleString * quotient; if(remainder > 0) aCnt += s.Substring(0,(int)remainder).Count(c=>c =='a'); return aCnt; }
Seems like cookies are disabled on this browser, please enable them to open this website
Repeated String
You are viewing a single comment's thread. Return to all comments →
C# simple solution: