187. Repeated DNA Sequences(建立词典,遍历一遍 o(n))
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))的更多相关文章
- 【LeetCode】187. Repeated DNA Sequences 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/repeated ...
- [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 ...
- 187. Repeated DNA Sequences
题目: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: " ...
- 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 ...
- 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 ...
- 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 ...
- [LeetCode#187]Repeated DNA Sequences
Problem: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: ...
- [LeetCode] 187. Repeated DNA Sequences 解题思路
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
- 【LeetCode】187. Repeated DNA Sequences
题目: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: " ...
随机推荐
- openvpn 多机房互联
Server端安装配置 一.安装 1.下载及相关依赖包安装 wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.06.tar.gz ...
- VB学习之路基础(一)
1.VB不区分大小定,VB编辑器会自动更正. 2.每一行代码语句,没有语句结束符. 3.续行符:一个"空格"加上一个"下划线".不能在参数中间加续行符. 5.合 ...
- 【CF932E】Team Work/【BZOJ5093】图的价值 数学+NTT
[CF932E]Team Work 题意:求$\sum\limits_{i=1}^nC_n^ii^k$,答案模$10^9+7$.$n\le 10^9,k\le 5000$. [BZOJ5093]图的价 ...
- 关于Django的序列化
阅读目录 Django支持的序列化格式 Django的序列化 Django支持的序列化格式 1 2 3 4 Identifier Information xml Serializes to and f ...
- vue之介绍
vue的作者叫尤雨溪,中国人.自认为很牛逼的人物,也是我的崇拜之神. 关于他本人的认知,希望大家读一下这篇关于他的文章,或许你会对语言,技术,产生浓厚的兴趣.https://mp.weixin.qq. ...
- 《into100-创客+沙龙第4期:互联网产品用户需求挖掘与转化》圆满成功
5月16日,由麦思博和阿里云联合主办的<into100-创客+沙龙第4期:互联网产品用户需求挖掘与转化>圆满结束.现场100多位来自互联网及软件公司的产品经理.产品总监.开发经理.工程师及 ...
- Linux free命令详解
前段时间有个项目的用C写的,性能测试时发现内存泄露问题.关于怎么观察内存使用问题,free是很好用的一个命令. 参数讲解 bash-3.00$ freetotal used f ...
- hadoop完全分布式安装部署-笔记
规划: [hadoop@db01 ~]$ cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4 ...
- c# 实现ListView的排序
[问题描述]: 当点击列标题的时候,能够完成对该列排序,同时显示排序的箭头,再次点击,按照反序排序. [解决方法]: 1.创建一个类:ListViewColumnSorter继承IComparer接口 ...
- oracle(一)复习起航
住了三年的宿舍,前几天不得不搬走.也断了好几天网,所以顺手拿了本以前买的<oracle编程艺术>,感觉翻译的书就是有些地方读起来不通顺,好吃力. 还好以前有点oracle经验,不然真看不懂 ...