686. 重复叠加字符串匹配
class Solution:
def repeatedStringMatch(self, A: str, B: str) -> int:
if len(A) <= len(B):
n = len(B)//len(A)
if B in A * n:
return n
elif B in A * (n + 1):
return n + 1
elif B in A * (n + 2):
return n + 2
else:
pass
else:
if B in A:
return 1
elif B in A * 2:
return 2
else:
pass
return -1