Repeated DNA Sequences
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studying DNA, it is sometimes useful to identify repeated sequences within the DNA. Write a function to find all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule.
(找出字符串中长度为10的重复出现的子串)
Example:
1. 哈希表
遍历字符串,记录每个长度为10的子串出现的次数,具体实现过程如下:
1 | from collections import defaultdict |