Repeated DNA Sequences

Try to solve the Repeated DNA Sequences problem.


Given a string, s, that represents a DNA subsequence, and a number kk, return all the contiguous subsequences (substrings) of length kk that occur more than once in the string. The order of the returned subsequences does not matter. If no repeated substring is found, the function should return an empty set.

The DNA sequence is composed of a series of nucleotides abbreviated as AA, CC, GG, and TT. For example, ACGAATTCCGACGAATTCCG is a DNA sequence. When studying DNA, it is useful to identify repeated sequences in it.


  • 11 \leq s.length \leq 10310^3
  • s[i] is either A, C, G, or T.
  • 1k101 \leq k \leq 10


Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy