[Leetcode] 187. Repeated DNA Sequences

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

Subscribe to see which companies asked this question

1)直接在哈希表中存入10个字符恶毒字符串。
RE?
超过限额内存?

2)用两个Bit保存一个核苷酸,20Bit保存十个字符,用一个int即可。

public class Solution {
    public List findRepeatedDnaSequences(String s) {
        Map charMap = new HashMap<>();
        charMap.put('A',0);
        charMap.put('C',1);
        charMap.put('G',2);
        charMap.put('T',3);
        Map seqMap = new HashMap<>();
        List result = new ArrayList();
        int sum = 0;  
        for(int i=0; i

你可能感兴趣的:([Leetcode] 187. Repeated DNA Sequences)