Search⌘ K
AI Features

Repeated DNA Sequences

Explore how to detect repeated 10-letter sequences in DNA strings using the sliding window approach. This lesson helps you understand substring identification and efficient string manipulation to solve pattern recognition problems common in coding interviews.

Statement

A DNA sequence consists of a series of nucleotides, each represented by one of the characters 'A', 'C', 'G', or 'T'.

Given a string s representing a DNA sequence, find and return all 1010-letter-long substrings that appear more than once within s. The result may be returned in any order.

Constraints:

  • 11 \leq s.length 105\leq 10^5

  • s[i] is one of 'A', 'C', 'G', or 'T'

Examples

canvasAnimation-image
1 / 5

Understand the problem

Now, let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:

Repeated DNA Sequences

1.

Given the input s = "TTTTTTTTT", what is the output of finding all 1010-letter-long substrings that appear more than once?

A.

["TTTTTTTTT"]

B.

["TTTTTTTTTT"]

C.

[]

D.

["TTTTTTTTT", "TTTTTTTTTT"]


1 / 5

Figure it out!

We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.

Sequence - Vertical
Drag and drop the cards to rearrange them in the correct sequence.

1
2
3
4
5

Try it yourself

Implement your solution in the following coding playground.

Python
usercode > solution.py
def findRepeatedDnaSequences(s):
# Replace this placeholder return statement with your code
return list("O")
Repeated DNA Sequences