#K12621. Repeated Substring Detection
Repeated Substring Detection
Repeated Substring Detection
Given a string \( S \) consisting of lowercase English letters and an integer \( K \), determine whether there exists any substring in \( S \) that appears at least \( K \) times. A substring is defined as a contiguous block of characters in the string. Note that occurrences of a substring may overlap. For example, in the string "aaaaa", the substring "aa" appears 4 times.
If such a substring exists, output YES
; otherwise, output NO
.
inputFormat
The input is given via standard input (stdin) and consists of two lines. The first line contains the non-empty string ( S ) (only lowercase English letters). The second line contains an integer ( K ), representing the minimum number of occurrences required.
outputFormat
Output via standard output (stdout) a single line containing either YES
if there exists a substring that appears at least ( K ) times, or NO
otherwise.## sample
abcbabc
2
YES