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 6aadb4b commit 61e5e54Copy full SHA for 61e5e54
group-anagrams/soobing3.ts
@@ -0,0 +1,10 @@
1
+function groupAnagrams(strs: string[]): string[][] {
2
+ const map = new Map();
3
+
4
+ for(const str of strs) {
5
+ const key = str.split('').sort().join('');
6
+ const value = map.get(key);
7
+ map.set(key, value ? [...value, str] : [str])
8
+ }
9
+ return Array.from(map.values());
10
+};
0 commit comments