#187

Repeated DNA Sequences

specialist · 840 · lc medium +31 · verified · 52.9% accepted · 3,609 likes · top 43%

play →

Description

The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'.

- For example, "ACGAATTCCG" is a DNA sequence.

Given a DNA string s, return all 10-letter-long sequences (substrings) that occur more than once. You may return the answer in any order.

Example 1:

Input: s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"
Output: ["AAAAACCCCC","CCCCCAAAAA"]

Example 2:

Input: s = "AAAAAAAAAAAAA"
Output: ["AAAAAAAAAA"]

Code

1
2
3