Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 424 Bytes

686.md

File metadata and controls

27 lines (18 loc) · 424 Bytes

Repeated String Match

Description

link


Solution

  • 只能是1次或者2次

Code

O(n)

class Solution:
    def repeatedStringMatch(self, A: str, B: str) -> int:
        times = -(-len(B) // len(A))
        for i in range(2):
            if B in A*(times + i):
                return times + i
        return -1