deno.land / x / masx200_leetcode_test@10.6.5 / repeated-dna-sequences / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function findRepeatedDnaSequences(s: string): string[] { const L = 10; const ans: string[] = []; const cnt: Map<string, number> = new Map(); const n = s.length; for (let i = 0; i <= n - L; ++i) { const sub = s.slice(i, i + L); cnt.set(sub, (cnt.get(sub) || 0) + 1); if (cnt.get(sub) === 2) { ans.push(sub); } } return ans;}export default findRepeatedDnaSequences;
masx200_leetcode_test

Version Info

Tagged at
a year ago