We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1f58190 commit 479a691Copy full SHA for 479a691
group-anagrams/yihyun-kim1.js
@@ -0,0 +1,18 @@
1
+/**
2
+ * @param {string[]} strs
3
+ * @return {string[][]}
4
+ */
5
+const groupAnagrams = (strs) => {
6
+ const map = new Map();
7
+
8
+ for (const str of strs) {
9
+ const sorted = str.split("").sort().join("");
10
11
+ if (!map.has(sorted)) {
12
+ map.set(sorted, []);
13
+ }
14
+ map.get(sorted).push(str);
15
16
17
+ return [...map.values()];
18
+};
0 commit comments