A DNA sequence is a string of the letters `A`, `C`, `G` and `T`. Given a DNA string `s`, return every 10-letter substring that occurs more than once in `s`. The answer can be in any order.
A DNA sequence is a string of the letters A, C, G and T. Given a DNA string s, return every 10-letter substring that occurs more than once in s. The answer can be in any order.
Example 1:
Input: {"s":"AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"}
Output: ["AAAAACCCCC","CCCCCAAAAA"]
Constraints:
1≤s.length≤105
s[i] is one of 'A', 'C', 'G' or 'T'.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"}
Each base fits in 2 bits (A=00, C=01, G=10, T=11), so 10 bases fit in a 20-bit number h. Shifting in a base and masking to 20 bits slides the window by one.