Skip to content

Commit

Permalink
1668. Maximum Repeating Substring solved
Browse files Browse the repository at this point in the history
  • Loading branch information
danielteferadeti committed Nov 18, 2022
1 parent 40e598b commit 302f513
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Solution:
def maxRepeating(self, sequence: str, word: str) -> int:
nextStart = []
for i in range(len(sequence)):
if sequence[i]==word[0]:
nextStart.append(i)

Bestcount = 0
for start in nextStart:
seqCount = 0
i = start
while i < len(sequence):
if sequence[i:i+len(word)] == word:
seqCount += 1
i = i+len(word)
else:
break

Bestcount = max(Bestcount, seqCount)
return Bestcount


0 comments on commit 302f513

Please sign in to comment.