Skip to content

Commit e0b9ef8

Browse files
committed
Repeated_DNA_Sequences / 중급
1 parent e8548e0 commit e0b9ef8

File tree

1 file changed

+18
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)