• + 0 comments

    Python3 Solution

    def repeatedString(s, n):
        fullCount = n // len(s)
        leftCount = n % len(s)
        aCount = sum(1 if char == "a" else 0 for char in s)
        
        res = aCount * fullCount
        
        for i in range(leftCount):
            if s[i] == "a":
                res += 1
            
        return res