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.

Example:

Input: s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"

Output: ["AAAAACCCCC", "CCCCCAAAAA"]
 class Solution:
def findRepeatedDnaSequences(self, s):
"""
:type s: str
:rtype: List[str]
"""
d ={}
for i in range(len(s)-9):
if s[i:i+10] not in d:
d[s[i:i+10]]= 1
else:
d[s[i:i+10]]+= 1
res =[]
for i in d:
if d[i]>1:
res.append(i)
return res

187. Repeated DNA Sequences(建立词典,遍历一遍 o(n))的更多相关文章

  1. 【LeetCode】187. Repeated DNA Sequences 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/repeated ...

  2. [LeetCode] 187. Repeated DNA Sequences 求重复的DNA序列

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  3. 187. Repeated DNA Sequences

    题目: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: " ...

  4. 187. Repeated DNA Sequences (String; Bit)

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  5. leetcode 187. Repeated DNA Sequences 求重复的DNA串 ---------- java

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  6. Java for LeetCode 187 Repeated DNA Sequences

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  7. [LeetCode#187]Repeated DNA Sequences

    Problem: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: ...

  8. [LeetCode] 187. Repeated DNA Sequences 解题思路

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  9. 【LeetCode】187. Repeated DNA Sequences

    题目: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: " ...

随机推荐

  1. NHibernate.3.0.Cookbook第一章第六节Handling versioning and concurrency的翻译

    NHibernate.3.0.Cookbook第一章第六节Handling versioning and concurrency的翻译   第一章第二节Mapping a class with XML ...

  2. 新浪的动态策略灰度发布系统:ABTestingGateway

    原文链接:http://www.open-open.com/lib/view/open1439889185239.html ABTesingGateway 是一个可以动态设置分流策略的灰度发布系统,工 ...

  3. 经典把妹桥段:Flower dance开头对话

    听到一首很赞的钢琴曲,Flower Dance,其开头有一段英文对话,如下: Lucy:"They serve the purpose of changing hydrogen into b ...

  4. 解析xml文件的几种技术与Dom4j与sax之间的对比

    一.解析xml文件的几种技术:dom4j.sax.jaxb.jdom.dom 1.dom4j dom4j是一个Java的XML API,类似于jdom,用来读写XML文件的.dom4j是一个非常优秀的 ...

  5. jenkins遇到含中文路径的SVN地址时认证通不过

    安装插件:http://mirror.xmission.com/jenkins/plugins/subversion/2.5/subversion.hpi 可以解决svn中文目录问题 百度云:http ...

  6. POJ-1959 Darts

    Darts Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1286 Accepted: 741 Description Back ...

  7. cmake practice一文中安装可执行文件的方法

    在学习cmake practice第四章中,第四章的任务如下 修改 Helloworld 支持安装在本节开头我们定义了本节的任务如下:1,为工程添加一个子目录 src,用来存储源代码;2,添加一个子目 ...

  8. MapReduce分组

     分组:相同key的value进行分组  例子:如下输入输出,右边的第一列没有重复值,第二列取得是当第一列相同时第二例取最大值 分析:首先确定<k3,v3>,k3的选择两种方式, 方法1. ...

  9. 《机器学习实战》中的splitDataSet函数

    splitDataSet这个函数困扰了我好一阵子,为什么以某一特征值为标准进行划分数据集以后,变成了局部?例如,如果以第1个特征为0为标准进行划分,那么返回的结果集就是不含有此特征的结果集,如下图红框 ...

  10. HDU 2037 - 今年暑假不AC - [经典 选择不相交区间 问题]

    是一道很经典的选择不相交区间的问题. 关于选择不相交区间,可以参考刘汝佳.也可以参考:http://blog.csdn.net/dgq8211/article/details/7534488 以及模板 ...