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的更多相关文章

  1. lc面试准备:Repeated DNA Sequences

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

  2. LeetCode 187. 重复的DNA序列(Repeated DNA Sequences)

    187. 重复的DNA序列 187. Repeated DNA Sequences 题目描述 All DNA is composed of a series of nucleotides abbrev ...

  3. [LeetCode] Repeated DNA Sequences 求重复的DNA序列

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

  4. [Leetcode] Repeated DNA Sequences

    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. 【leetcode】Repeated DNA Sequences(middle)★

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

  7. LeetCode() Repeated DNA Sequences 看的非常的过瘾!

    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. 187. Repeated DNA Sequences

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

随机推荐

  1. Java Web技术总结(目录)

    来源于:http://www.jianshu.com/p/539bdb7d6cfa Java Web技术经验总结(一) Java Web技术经验总结(二) Java Web技术经验总结(三) Java ...

  2. overlay-3

    if(typeof Shadowbox=="undefined"){ throw"Unable to load Shadowbox, no base library ad ...

  3. iOS开发中的错误整理,线程之间通信练习,加载图片的练习中出现的错误 -- Http请求错误

    控制台打印:Application Transport Security has blocked a cleartext HTTP (http://) resource load since it i ...

  4. struts2理解

    (1) Struts2(一)---struts2的环境搭建及实例 (2) struts2(二)---ModelDriven模型驱动 (3) Struts2属性驱动与模型驱动 (4)

  5. C语言+SDL2 图形化编程

    程设大作业小火车第一版本是命令行界面,第二版本是图形化界面,由于egg库对以后工程开发没有用,我不想用egg库,花了很长时间浏览了一下OpenGL的中文教程,觉得好复杂,需要看很多很多才能写出个简单的 ...

  6. Oracle中的伪列

    分页查询中,需要用到伪列rownum,代码如下: select * from (select rownum rn, name from cost where rownum <= 6) where ...

  7. Oracle单组函数

    --Upper  -------把字符转换成大写       SELECT Upper ('abcde') FROM dual ; --Lower   ----- 把字符转换成小写      SELE ...

  8. HBase概念学习(十)HBase与MongDB等NoSQL数据库对照

    转载请注明出处: jiq•钦's technical Blog - 季义钦 一.开篇 淘宝之前使用的存储层架构一直是MySQL数据库,配合以MongDB,Tair等存储. MySQL因为开源,而且生态 ...

  9. linux桌面应用开发之折腾

    1 起因 需要开发一个wifi定位的应用,最先在android下搞,后来因为多网卡的原因要换平台,经历了windows,最终选择用kaili linux.debian系的linux,开发桌面应用怎么办 ...

  10. TEXT宏,TCHAR类型

    TCHAR *ptch = TEXT("This is a const string."); 如果使用UNICODE字符集, 则TEXT("This is a const ...