One minute
Leetcode 1566
1566. Detect Pattern of Length M Repeated K or More Times The idea of this can be show by this image
func containsPattern(arr []int, m int, k int) bool {
counter := 0
for i := 0; i < len(arr) - m; i++ {
if arr[i] != arr[i+m] {
counter = 0
} else {
counter++
}
if counter == (k-1)*m {
return true
}
}
return false
}
Read other posts