187. Repeated DNA Sequences

class Solution {
    public List<String> findRepeatedDnaSequences(String s) {
        Set<String> set=new HashSet<String>();
        Set<String> res=new HashSet<String>();
        for(int i=0;i+10<=s.length();i++)
        {
            String str=s.substring(i,i+10);
            if(set.contains(str))
                res.add(str);
            else
                set.add(str);
        }
        return new ArrayList<String>(res);
    }
}

  

转载于:https://www.cnblogs.com/asuran/p/7734050.html

上一篇:leetcode-187-重复的DNA序列


下一篇:[Leetcode Weekly Contest]187