• + 0 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;
        }