Skip to content

Commit 3721565

Browse files
Create 187-Repeated-DNA-Sequences.java
1 parent 6c9a71d commit 3721565

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public List<String> findRepeatedDnaSequences(String s) {
3+
HashSet<String> set = new HashSet<>();
4+
int start = 0;
5+
HashSet<String> ans = new HashSet<>();
6+
for (int end = 10; end<=s.length(); end++) {
7+
if (set.contains(s.substring(start, end)))
8+
ans.add(s.substring(start, end));
9+
set.add(s.substring(start, end));
10+
start++;
11+
}
12+
List<String> list = new ArrayList<>(ans);
13+
return list;
14+
}
15+
}

0 commit comments

Comments
 (0)