leetcode 187: Repeated DNA Sequences

Total Accepted: 1161 Total Submissions: 6887

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

[分析]

HASHMAP方法会EXCEED SPACE LIMIT.

因为只有4个字母,所以可以创建自己的hashkey, 每两个BITS, 对应一个 incoming character. 超过20bit 即10个字符时, 只保留20bits.

[注意]

1. (hash

public class Solution { public List findRepeatedDnaSequences(String s) { List res = new ArrayList(); if(s==null || s.length() map = new HashMap(); map.put('A', 0); map.put('C', 1); map.put('G', 2); map.put('T', 3); Set set = new HashSet(); Set unique = new HashSet(); for(int i=0; i

点击复制链接 与好友分享!回本站首页
您对本文章有什么意见或着疑问吗?请到论坛讨论您的关注和建议是我们前行的参考和动力
上一篇:C++ Redis mset 二进制数据接口封装方案
下一篇:LeetCode --- 42. Trapping Rain Water
相关文章

LeetCode题目9 Count and Say

[LeetCode] Best Time to Buy an

[leetcode]Implement strStr()

leetcode代码分类汇总之-树

[LeetCode]Convert Sorted Array t

[LeetCode]Container With Most Water

[LeetCode]Construct Binary Tree

[LeetCode]Construct Binary Tree

[LeetCode]Merge Sorted Array

[LeetCode]Merge k Sorted Lists

图文推荐

leetcode 187: Repeated DNA Sequences
ZOJ 3640 Help Me
leetcode 187: Repeated DNA Sequences
CF 518C(Anya and
leetcode 187: Repeated DNA Sequences
hdu 1016 Prime R
UVA - 11987 - A

分类:默认分类 时间:2015-03-12 人气:3
本文关键词:
分享到:

相关文章

Copyright (C) quwantang.com, All Rights Reserved.

趣玩堂 版权所有 京ICP备15002868号

processed in 0.056 (s). 10 q(s)