1 class Solution(object): 2 def repeatedStringMatch(self, A, B): 3 """ 4 :type A: str 5 :type B: str 6 :rtype: int 7 """ 8 lenb = len(B) 9 # 用来暂存原A串 10 temp = A 11 for i in range(1, int((lenb * 2) / (len(temp))) + 3): 12 # 重复叠加A串 13 A = temp * i 14 # B串若是A的子串,则A串长度大于B串 15 if len(A) < lenb: 16 continue 17 if B in A: 18 return i 19 return -1