[
string
counter
]
BinarySearch 0615 Repeated K-Length Substrings
Problem statement
https://binarysearch.com/problems/Repeated-K-Length-Substrings/
Solution
Just check all substrings of length k
and use counter.
Complexity
It is O(nk)
for time and space.
Code
class Solution:
def solve(self, s, k):
return sum(i != 1 for i in Counter(s[i:i+k] for i in range(len(s) - k + 1)).values())