302. Ten-Letter Stretches That Appear Twice
A sequence is written in the letters A, C, G and T. Print every stretch
of exactly 10 letters that occurs MORE THAN ONCE anywhere in it, each listed once,
in alphabetical order, separated by single spaces. Print none if there is no
such stretch.
Stretches may overlap. In AAAAAAAAAAA the 10-letter stretch AAAAAAAAAA
starts at index 0 and again at index 1, so it counts as repeated.
There are len - 9 stretches in total. Count each in a map and report those
whose count is at least 2. The two details that decide correctness:
report each repeated stretch ONCE, however many times it occurs
a string of exactly 10 letters has one stretch, so nothing repeats
Collecting into a list rather than a set is the usual error, because a stretch occurring three times is then printed twice.
Constraints - `1 ≤ length ≤ 100000` - Every character is `A`, `C`, `G` or `T`.
Input
One line: the sequence, made only of the letters A, C, G and T.
Output
Print the repeated 10-letter stretches, each once, in alphabetical order, separated by single spaces. Print none if there are none.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.