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. Shell语法整理,持续维护

    Shell shell条件表达式: CONDITIONAL EXPRESSIONSConditional expressions are used by the [[ compound command ...

  2. 问题记录 为ubuntu16.04添加windows字体(解决JIRA图表乱码的问题)

    最近遇到了JIRA在新的ubuntu机器上图表的中文无法正确显示的问题,解决的方法是,为ubuntu安装中文字体,我们选择把windows上的字体复制到ubuntu上来安装的方法,步骤如下: 从win ...

  3. pandas生成时间列表(某段连续时间或者固定间隔时间段)

    python生成一个日期列表 首先导入pandas import pandas as pd def get_date_list(begin_date,end_date): date_list = [x ...

  4. ABP之项目的搭建

    ABP是一个非常优秀的框架,使用模块化的管理方式,将当前比较优秀的技术集成到了这个框架中,方便开发者快速搭建自己的网站.作为ABP学习的第一篇,先将ABP框架跑起来看看再说. 1.首先需要去官网下载相 ...

  5. @font-face 字体图标的应用

    所谓字体图标,顾名思义就是图标以字体的形式存在,可以利用 font-size.color 对字体图标的大小和颜色进行渲染.将小图标集中放到字体库里,利用css3 @font-face 引用图标,不仅有 ...

  6. 批量转换gbk编码的java代码为utf8

    #!/bin/bash echo $1 echo $# if [ ! $# -eq 1 ]; then     echo "usage:  ./gbk2utf8.sh src"   ...

  7. Redis、Mongo - 目录

    redis redis字典取数据.列表取数据(数据量大) redis 实现栈 - python mongodb - 可视化工具 / pymongo - 使用方法

  8. cookie的封装写法

    设置cookie 三个参数分别代表:键,值,过期时间,这个封装方法可以完成cookie的储存   以及cookie的删除(过期时间设为赋值) function setCookie(cname,cval ...

  9. php 中date显示时间不对与Linux文件乱码问题

    php 中date显示时间不对解决办法如下1.修改/etc/php.ini文件 在里头中找到data.timezone =去掉它前面的分号';' 然后设置data.timezone = “Asia/S ...

  10. Python装饰器与面向切面编程(转)

    add by zhj: 装饰器的作用是将代码中可以独立的功能独立出来,实现代码复用,下面那个用于统计函数运行时间的装饰器就是很好的例子,我们不用修改原有的函数和调用原有函数的地方,这遵循了开闭原则.装 ...