Repeated DNA Sequences
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"].
public class Solution {
public List<String> findRepeatedDnaSequences(String s) {
List<String> list = new ArrayList<String>();
Set<String> temp = new HashSet<String>();
if (s == null || s.length() <= )
return list;
Set<String> set = new HashSet<String>();
for (int i = ; i <= s.length(); i++) {
if (set.contains(s.substring(i - , i))) {
temp.add(s.substring(i - , i));
} else {
set.add(s.substring(i - , i));
}
}
return new ArrayList<String>(temp);
}
}
Repeated DNA Sequences的更多相关文章
- lc面试准备:Repeated DNA Sequences
1 题目 All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: &quo ...
- LeetCode 187. 重复的DNA序列(Repeated DNA Sequences)
187. 重复的DNA序列 187. Repeated DNA Sequences 题目描述 All DNA is composed of a series of nucleotides abbrev ...
- [LeetCode] Repeated DNA Sequences 求重复的DNA序列
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: "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 ...
- LeetCode() Repeated DNA Sequences 看的非常的过瘾!
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 ...
- 187. Repeated DNA Sequences
题目: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: " ...
随机推荐
- python 条件判断和循环
一.条件判断 if if age>= 18: 记住在判断语句后面要加上 : 还有要注意他的缩进 age = 20if age >= 18: print 'your age ...
- Windows下python的配置
Windows下python的配置 希望这是最后一次写关于python的配置博客了,已经被python的安装烦的不行了.一开始我希望安装python.手动配置pip并使用pip安装numpy,然而发现 ...
- BZOJ-1968 COMMON 约数研究 数论+奇怪的姿势
1968: [Ahoi2005]COMMON 约数研究 Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1513 Solved: 1154 [Submit] ...
- 【bzoj1202】 HNOI2005—狡猾的商人
http://www.lydsy.com/JudgeOnline/problem.php?id=1202 (题目链接) 题意 给出m段区间和,判断是否存在某段区间与之前读入的区间相矛盾. Soluti ...
- POJ1201 Intervals
Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a p ...
- 友盟iOS推送配置(从真机调试到推送)
下面我来讲解一下友盟iOS的推送配置,其实友盟只是一个示例,换做其余的第三方推送服务也会适用,只是第三方的后面服务变了而已. iOS推送(包括真机调试)所需要的步骤和文件如下: 备注:这里我将省略掉一 ...
- 洛谷P1736 创意吃鱼法
题目描述 回到家中的猫猫把三桶鱼全部转移到了她那长方形大池子中,然后开始思考:到底要以何种方法吃鱼呢(猫猫就是这么可爱,吃鱼也要想好吃法 ^_*).她发现,把大池子视为01矩阵(0表示对应位置无鱼,1 ...
- ci创建zip
public function createZip() { $this->load->library("zip"); $name = "test.text&q ...
- 锋利的jQuery-2--一个显示和隐藏的例子,主要看写法
例子:如图,默认不显示全部,点击按钮来回切换,全部显示是一部分推荐的品牌高亮. $(function(){ //dom加载完再执行 var category = $('ul li:gt(5):not( ...
- (转) 新的开始之Win7、CentOS 6.4 双系统 硬盘安装
http://blog.csdn.net/cnclenovo/article/details/11358447