leetcoe-686

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
上一篇:LINQ之路21:LINQ to XML之生成X-DOM(Projecting)


下一篇:Java中使用代理方式发送指定请求http,https(get,post等)