We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 820bb27 commit efb0c41Copy full SHA for efb0c41
solution/0187.Repeated DNA Sequences/Solution.java
@@ -0,0 +1,16 @@
1
+class Solution {
2
+ public List<String> findRepeatedDnaSequences(String s) {
3
+ Map<String, Integer> map = new HashMap<>();
4
+ for (int i = 10; i <= s.length(); ++i) {
5
+ String sub = s.substring(i - 10, i);
6
+ map.put(sub, map.getOrDefault(sub, 0) + 1);
7
+ }
8
+ List<String> res = new ArrayList<>();
9
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
10
+ if (entry.getValue() > 1) {
11
+ res.add(entry.getKey());
12
13
14
+ return res;
15
16
+}
0 commit comments