水过去
class Solution { public List<String> findRepeatedDnaSequences(String s) { HashMap<String, Integer> hashMap = new HashMap<>(); ArrayList<String> list = new ArrayList<>(); for (int i = 0; i < s.length(); i++) { if (i + 9 >= s.length()) break; String temp = s.substring(i, i + 10); if (hashMap.containsKey(temp)) { Integer integer = hashMap.get(temp); integer += 1; hashMap.put(temp, integer); }else{ hashMap.put(temp,1); } } for (Map.Entry<String, Integer> entry : hashMap.entrySet()) { // System.out.println(entry); if (entry.getValue() > 1) { list.add(entry.getKey()); } } return list; } }