Leetcode OJ : Repeated DNA Sequences hash python solution
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的更多相关文章
- [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] Repeated DNA Sequences hash map
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
- Leetcode:Repeated DNA Sequences详细题解
题目 All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: " ...
- 【LeetCode】Repeated DNA Sequences 解题报告
[题目] All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: &quo ...
- [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 ...
- 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 ...
- 【leetcode】Repeated DNA Sequences(middle)★
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 解题思路
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...
随机推荐
- Objective C 四舍五入,float处理
NSLog(@"平方:%.f", pow(3,2) ); //result 9 NSLog(@"上舍入:%.f", ceil(3.000000000001)); ...
- Otto Product Classification Winner's Interview: 2nd place, Alexander Guschin ¯\_(ツ)_/¯
Otto Product Classification Winner's Interview: 2nd place, Alexander Guschin ¯\_(ツ)_/¯ The Otto Grou ...
- OD之窗口界面
- hdu 3864 D_num
思路:给一个数n,是否只有4个约数(包括1),也就是找3个大于1的约数. 而任何一个数都可由质数表示,所以对于给定的数,只需要进行质因数分解.这里有 2种情况:如果有3个一样的质因数,则满足条件:否则 ...
- Java发送post请求
package com.baoxiu.test; import java.io.BufferedReader;import java.io.InputStreamReader;import java. ...
- EdasStudio 开发工具用户手册
EdasStudio 开发工具用户手册 Edas 开发组2015-8-14 1. 下载安装插件 EdasStudio是EDAS的开发工具,是一个Eclipse Plugins,打开Eclipse的He ...
- Mysql一主多从和读写分离配置简记
近期开发的系统中使用MySQL作为数据库,由于数据涉及到Money,所以不得不慎重.同时,用户对最大访问量也提出了要求.为了避免Mysql成为性能瓶颈并具备很好的容错能力,特此实现主从热备和读写分离. ...
- SPRING IN ACTION 第4版笔记-第八章Advanced Spring MVC-006-Pizza例子的支付流程
一. 1. 2.payment-flow.xml <?xml version="1.0" encoding="UTF-8"?> <flow x ...
- Git教程之分支管理之二
分支管理策略 通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息.如果要强制禁用Fast forward模式,Git就会在merge时生成一个 ...
- RedMine项目管理系统安装问题(Windows版一键安装包)
安装准备: 操作环境:VMware10 下安装的windows10 系统 使用软件:<bitnami-redmine---windows-installer.exe> 问题描述: 安装过程 ...