Back to DSA sheet
Repeated DNA Sequences
MediumArraysGiven a DNA string of letters A, C, G, T, return every 10-letter substring that appears more than once. Each answer is listed once.
Input format (stdin): a single line, the DNA string. Output each repeated 10-letter sequence on its own line, in ascending (sorted) order; print nothing if there are none.
Examples
Input: AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT
Output: AAAAACCCCC
CCCCCAAAAA
Both 10-letter windows repeat.
Constraints
- 1 <= length <= 10^5
- letters in {A, C, G, T}
Sheets
NeetCode 250
repeated-dna-sequences.cpp2 sample tests
Loading editor
Test results
Run the sample tests to check your solution against expected output.
Custom input (stdin)
Output
Run your code to see its output.