#C5409. Repeating Substring Detection
Repeating Substring Detection
Repeating Substring Detection
Given a string S and an integer K, determine whether there exists a substring in S that occurs at least K
times. A substring is defined as a contiguous sequence of characters within the string. The frequency of a substring is the number of times it appears in S (overlapping occurrences are counted).
The solution should read input from stdin and print the result for each test case on stdout. If any substring appears at least K times, output YES
; otherwise, output NO
.
For example, for S = "abracadabra"
and K = 3
, since the substring "a" appears 5 times (which is at least 3), the output is YES
.
inputFormat
The input is read from standard input and has the following format:
T S1 K1 S2 K2 ... ST KT
Here, T
is the number of test cases. For each test case, a string S
and an integer K
are provided (separated by spaces).
outputFormat
For each test case, output a single line containing either YES
if there exists a substring in S that occurs at least K times, or NO
otherwise.
The output should be printed to standard output.
## sample3
abracadabra 3
banana 2
abcdef 2
YES
YES
NO
</p>