deno.land / x / masx200_leetcode_test@10.6.5 / uncommon-words-from-two-sentences / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export default function uncommonFromSentences( s1: string, s2: string,): string[] { const a = s1.split(" ");
const b = s2.split(" ");
const cnts = new Map<string, number>();
for (const word of [...a, ...b]) { cnts.set(word, (cnts.get(word) ?? 0) + 1); }
return Array.from(cnts.keys()).filter((k) => 1 === cnts.get(k));}
masx200_leetcode_test

Version Info

Tagged at
a year ago