Skip to content

Commit 10e8121

Browse files
authored
Merge pull request neetcode-gh#2347 from gonch0/main
2 parents c1aaff3 + c4d19ba commit 10e8121

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @param {string} s
3+
* @return {string[]}
4+
*/
5+
var findRepeatedDnaSequences = function (s) {
6+
const seen = new Set();
7+
const res = new Set();
8+
const arr = Array.from(s);
9+
10+
for (let l = 0; l < arr.length - 9; l++) {
11+
const sequence = s.slice(l, l + 10);
12+
13+
if (seen.has(sequence)) {
14+
res.add(sequence);
15+
} else {
16+
seen.add(sequence);
17+
}
18+
}
19+
20+
return Array.from(res);
21+
};

0 commit comments

Comments
 (0)