244. Repeated DNA Sequences (Count)

MediumStringString

Given a DNA string s composed of 'A','C','G','T', return the number of distinct 10-letter-long substrings that occur more than once in s.

Input: A quoted DNA string.

Output: Integer — count of repeated 10-mers.

Examples

Example 1
Input: "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"
Output: 2
Explanation: Two 10-mers repeat.
Example 2
Input: "AAAAAAAAAAAAA"
Output: 1
Explanation: 'AAAAAAAAAA' repeats.
Example 3
Input: "ACGT"
Output: 0
Explanation: Too short.

Constraints

Asked by

BloombergAmazonMicrosoftMetaGoogle
Solve this problem in the editor →