Files
LeetCode-Go/leetcode/1668.Maximum-Repeating-Substring/1668. Maximum Repeating Substring.go

19 lines
274 B
Go

package leetcode
import (
"strings"
)
func maxRepeating(sequence string, word string) int {
for i := len(sequence) / len(word); i >= 0; i-- {
tmp := ""
for j := 0; j < i; j++ {
tmp += word
}
if strings.Contains(sequence, tmp) {
return i
}
}
return 0
}