Skip to content

Commit 5a4fbd3

Browse files
committed
Create: 0187-repeated-dna-sequences.ts
1 parent ee7a3bc commit 5a4fbd3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function findRepeatedDnaSequences(s: string): string[] {
2+
let seen = new Set<string>();
3+
let res = new Set<string>();
4+
5+
for (let i = 0; i < s.length - 9; i++) {
6+
let cur = s.slice(i, i + 10);
7+
if (seen.has(cur)) {
8+
res.add(cur);
9+
}
10+
seen.add(cur);
11+
}
12+
13+
return Array.from(res);
14+
}

0 commit comments

Comments
 (0)