• + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/Vh5davsSkfA

    long ccount(string s) {
        return count(s.begin(), s.end(), 'a');
    }
    
    long repeatedString(string s, long n) {
        return (n / s.size()) * ccount(s) + ccount(s.substr(0, n % s.size()));
    }