#K63542. Detect Repeated Subsequence in Genetic Sequence
Detect Repeated Subsequence in Genetic Sequence
Detect Repeated Subsequence in Genetic Sequence
In this problem, you are given a genetic sequence represented as a string s
and an integer k
. Your task is to determine whether there exists any subsequence of length k
that occurs more than once in s
.
More formally, you need to check if there exist two different indices i and j (with i ≠ j) such that:
\(s[i:i+k] = s[j:j+k]\)
If such a subsequence exists, print YES
; otherwise, print NO
.
Note: The subsequences must be contiguous segments of the string. The input will be provided via standard input and the output should be written to standard output.
inputFormat
The input consists of two lines:
- The first line contains an integer
k
denoting the length of the subsequence to check. - The second line contains a string
s
representing the genetic sequence.
It is guaranteed that 1 ≤ k ≤ |s|
, where |s|
is the length of the string.
outputFormat
Output YES
if there is any repetition of a subsequence of length k
in s
; otherwise, output NO
.
3
ATCGATCGA
YES