@@ -0,0 +1,1083 @@
+public class Solution %7B%0A    public List%3CString%3E findRepeatedDnaSequences(String s) %7B%0A        List%3CString%3E result = new ArrayList%3CString%3E();%0A        if(s == null %7C%7C s.length() %3C= 10)%7B%0A            return result;%0A        %7D%0A        HashMap%3CInteger, Boolean%3E hm = new HashMap%3CInteger, Boolean%3E();%0A        for(int i = 0; i %3C= s.length() - 10; i ++)%7B%0A            int subint = dnaToInt(s.substring(i, i+10));%0A            if(hm.containsKey(subint))%7B%0A                if(!hm.get(subint))%7B%0A                    result.add(s.substring(i, i+10));%0A                    hm.put(subint, true);%0A                %7D%0A            %7Delse%7B%0A                hm.put(subint, false);%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A    %0A    private int dnaToInt(String s)%7B%0A        String result = %22%22;%0A        for(int i = 0; i %3C s.length(); i ++)%7B%0A            if (s.charAt(i) == 'A') result += %220%22;%0A            if (s.charAt(i) == 'C') result += %221%22;%0A            if (s.charAt(i) == 'G') result += %222%22;%0A            if (s.charAt(i) == 'T') result += %223%22;%0A        %7D%0A        return Integer.parseInt(result, 4);%0A    %7D%0A%7D

Q187 Repeated DNA Sequences