Understandable Python Solution


  • 0
    H
    class Solution(object):
        def repeatedStringMatch(self, A, B):
            """
            :type A: str
            :type B: str
            :rtype: int
            """
            temp = ""
            count = 0
            while len(temp) < len(B):
                temp+=A
                count += 1
                if B in temp:
                    return count
            temp += A
            if B in temp:
                return count + 1
            return -1
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.