1class Solution:2def repeatedStringMatch(self, A: str, B: str) -> int:3if len(A) >= len(B):4if B in A:5return 16elif B in A * 2:7return 28else:9return -110prefix = max(0, B.find(A)) # prefix -- length of A111repeat, postfix = divmod(len(B) - prefix, len(A)) # postfix -- length of A212repeat += bool(prefix) + bool(postfix)13if B in A * repeat:14return repeat15else:16return -1