Skip to content

Commit f4d8da7

Browse files
committed
Add solution #884
1 parent 9d4b438 commit f4d8da7

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/**
22
* 884. Uncommon Words from Two Sentences
3-
* https://leetcode.com/problems/uncommon-words-from-two-sentences/submissions/
3+
* https://leetcode.com/problems/uncommon-words-from-two-sentences/
44
* Difficulty: Easy
55
*
6-
* A sentence is a string of single-space separated words where each word consists
7-
* only of lowercase letters.
6+
* A sentence is a string of single-space separated words where each word
7+
* consists only of lowercase letters.
88
*
9-
* A word is uncommon if it appears exactly once in one of the sentences, and does
10-
* not appear in the other sentence.
9+
* A word is uncommon if it appears exactly once in one of the sentences,
10+
* and does not appear in the other sentence.
1111
*
12-
* Given two sentences s1 and s2, return a list of all the uncommon words. You may
13-
* return the answer in any order.
12+
* Given two sentences s1 and s2, return a list of all the uncommon words.
13+
* You may return the answer in any order.
1414
*/
1515

1616
/**
@@ -20,7 +20,6 @@
2020
*/
2121
var uncommonFromSentences = function(s1, s2) {
2222
const map = new Map();
23-
2423
(s1 + ' ' + s2).split(/\s+/).forEach(s => map.set(s, (map.get(s) || 0) + 1));
2524
return [...map].reduce((a, [k, c]) => c === 1 ? [...a, k] : a, []);
2625
};

0 commit comments

Comments
 (0)