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 9075685 commit 27c1b4aCopy full SHA for 27c1b4a
1 file changed
group-anagrams/reeseo3o.js
@@ -0,0 +1,19 @@
1
+/**
2
+ * TC: O(n * k log k) — 각 단어(k) 정렬 × n개
3
+ * SC: O(n * k)
4
+ */
5
+const groupAnagrams = (strs) => {
6
+ const map = new Map();
7
+
8
+ for (const str of strs) {
9
+ const key = str.split("").sort().join("");
10
11
+ if (!map.has(key)) {
12
+ map.set(key, []);
13
+ }
14
15
+ map.get(key).push(str);
16
17
18
+ return Array.from(map.values());
19
+};
0 commit comments