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. 应用程序创建自己的奔溃转储(crash dump)文件

    1.注册自定义的UnhandledExceptionFilter,C/C++ Runtime Library下需要注意自定义handler被移除(hook kernel32.dll的SetUnhand ...

  2. C语言qsort用法

    一.对int类型数组排序 int num[100]; Sample: int cmp ( const void *a , const void *b ) { return *(int *)a - *( ...

  3. Nhibernate学习

    Contains 缓存中是否存在SessionFactoryBizCom.GetInstance().GetCurrentSession().Contains(t1) Evict 临时状态(Trans ...

  4. 【转】.NET Framework、C#语言、IDE、CLR 版本历史及其差异

    原文地址: http://www.cnblogs.com/PurpleCow/archive/2012/06/17/2552780.html http://www.cnblogs.com/lhking ...

  5. Oracle备份恢复之热备份恢复及异机恢复

    原理: 数据库必须运行在归档模式下,否则备份没有意义.备份前冻结块头,使scn号不变化,然后cp物理文件,最后解冻块头.此过程dml语句可以正常执行,动作被写在日志文件里面,当解冻scn号后,日志文件 ...

  6. Oracle体系结构之联机日志文件管理

    日志文件分类:重做日志文件 归档日志文件 警告日志文件 跟踪日志文件 redo_log_file文件作用: 1)维护数据一致性 2)记录了数据库里的更改操作 redo_log_friles以组为单位, ...

  7. consul Consul vs. ZooKeeper, doozerd, etcd

    小结 1.Consul 功能更丰富: 2. 暴露http接口避免暴露系统复杂性 The Consul clients expose a simple HTTP interface and avoid ...

  8. Python实现简单HTTP服务器(二)

    实现简单web框架 一.框架(MyWeb.py) # coding:utf-8 import time # 设置静态文件根目录 HTML_ROOT_DIR = "./html" c ...

  9. 关于LeNet-5卷积神经网络 S2层与C3层连接的参数计算的思考???

    https://blog.csdn.net/saw009/article/details/80590245 关于LeNet-5卷积神经网络 S2层与C3层连接的参数计算的思考??? 首先图1是LeNe ...

  10. 用Monitor简单3步监控中间件ActiveMQ

    Apache ActiveMQ是一个基于JMX规范的纯Java消息中间件,它为应用系统提供高效.灵活的消息同步与异步传输处理.存储转发.可靠传输的特性. 消息队列对于应用的健康运行非常重要,作为运维人 ...