Total Accepted: 3790 Total Submissions: 21072

 
 

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"].

很水的hashtable

 class Solution:
# @param s, a string
# @return a list of strings
def findRepeatedDnaSequences(self, s):
hashset, addedset, retlist = set(), set(), []
for x in range(len(s)):
substr = s[x: x + 10]
if substr in hashset:
if substr not in addedset:
retlist.append(substr)
addedset.add(substr)
else:
hashset.add(substr)
return retlist

Leetcode OJ : Repeated DNA Sequences hash python solution的更多相关文章

  1. [LeetCode#187]Repeated DNA Sequences

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

  2. [LeetCode] Repeated DNA Sequences hash map

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

  3. Leetcode:Repeated DNA Sequences详细题解

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

  4. 【LeetCode】Repeated DNA Sequences 解题报告

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

  5. [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 ...

  6. 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 ...

  7. 【leetcode】Repeated DNA Sequences(middle)★

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

  8. 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 ...

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

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

随机推荐

  1. 1201: [HNOI2005]数三角形 - BZOJ

    Description Input 大三角形的所有短边可以看成由(n+1)*n/2个单位三角形的边界组成.如下图的灰色三角形所示.其中第1排有1个灰色三角形,第2排有2个灰色三角形,……,第n排有n个 ...

  2. spoj 62

    看了题解  自己好水   ...... #include <cstdio> #include <cstdlib> struct node { int x,y; }; node ...

  3. C++11新特性:自动类型推断和类型获取

    声明:本文是在Alex Allain的文章http://www.cprogramming.com/c++11/c++11-auto-decltype-return-value-after-functi ...

  4. 关于用 MySQL 存储 Emoji

    http://www.v2ex.com/t/137724 如果你希望让你的网站或者 App 支持 Emoji,那么在初次设置 MySQL 时,有一些细节你需要知道. Emoji Emoji 字符的特殊 ...

  5. mysql 查询重复值命令

    积累备忘啊: ; 从t_maintenanceinfo表查询重复记录的mtiId 和ip字段,以及重复条数

  6. dtp--eclipse的安装数据源管理的一个插件的安装方法

    1.  下载eclipse dtp 插件 http://download.eclipse.org/datatools/updates/1.11 help——>install new softwa ...

  7. Weblogic下部署的应用,当更新文件时需要重新安装部署

    JSP页面检查(秒):-1 Servlet重新加载检查(秒):-1 -1说明从不检查,故当更新文件时,需要重新部署,或重新安装部署.

  8. CURL与PHP-CLI的应用【CURL篇】

    curl是一个极为强大的HTTP传输工具,支持文件的上传和下载; curl在命令行下的使用 命令参数 -a/--append 上传文件时,附加到目标文件 -A/--user-agent <str ...

  9. VC中支持中文的字符串比较函数

    VS2008开发环境,多字符集和UNICODE字符集都可用. WCHAR * mbcsToUnicode(const char *zStr) { int nByte; WCHAR *zMbcsStr; ...

  10. Android:再按一次退出程序

    感觉这种效果比较友好 //两秒内按返回键两次退出程序 private long exitTime = 0; @Override public boolean onKeyDown(int keyCode ...