Practice/Google/Leetcode 187. Repeated DNA Sequences
CodingOptional
You are analyzing a DNA sequence represented as a string containing only the characters 'A', 'C', 'G', and 'T'. Your task is to identify all 10-character-long subsequences that appear more than once in the given DNA string.
Return a list of all such duplicate sequences. The order of sequences in the output does not matter, but each duplicate sequence should appear only once in the result.
Example 1:
Input: s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT" Output: ["AAAAACCCCC", "CCCCCAAAAA"] Explanation: "AAAAACCCCC" appears at indices 0 and 10. "CCCCCAAAAA" appears at indices 5 and 15.
Example 2:
Input: s = "AAAAAAAAAAAAA" Output: ["AAAAAAAAAA"] Explanation: The 10-character sequence "AAAAAAAAAA" appears 4 times starting at indices 0, 1, 2, and 3.
Example 3:
Input: s = "ACGTACGTAC" Output: [] Explanation: The string is only 10 characters long, so there is only one possible 10-character substring, which doesn't repeat.