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 fdf3120 commit 9bd9372Copy full SHA for 9bd9372
group-anagrams/soobing.ts
@@ -0,0 +1,14 @@
1
+function groupAnagrams(strs: string[]): string[][] {
2
+ const map = new Map<string, string[]>();
3
+
4
+ for (let i = 0; i < strs.length; i++) {
5
+ const key = strs[i].split("").sort().join("");
6
+ const group = map.get(key);
7
+ if (group) {
8
+ group.push(strs[i]);
9
+ } else {
10
+ map.set(key, [strs[i]]);
11
+ }
12
13
+ return [...map.values()];
14
+}
0 commit comments