本文共 1701 字,大约阅读时间需要 5 分钟。
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.
For example,
Given s = “AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT”,
Return:
[“AAAAACCCCC”, “CCCCCAAAAA”].Hash Table
和Bit Manipulation
来处理。 备注:采用hash_map
来做时,自己电脑上可以编译通过,但是LeetCode提示不存在hash_map
对象。故改为使用map
,但效率较低。/************************************************************* * @Author : 楚兴 * @Date : 2015/2/8 11:07 * @Status : Accepted * @Runtime : 238 ms*************************************************************/#include#include #include #include
转载地址:http://mjczl.baihongyu.com/