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 f5afe89 commit a7fec99Copy full SHA for a7fec99
โgroup-anagrams/anniemon.jsโ
@@ -0,0 +1,23 @@
1
+/**
2
+ * ์๊ฐ ๋ณต์ก๋:
3
+ * ์ ๋ ฌ ์์ ์ ๊ฐ ๋ฌธ์์ด์ ๊ธธ์ด๊ฐ m์ผ ๋ O(m logm)์ด๊ณ , ์ด strs์ ๊ธธ์ด๋งํผ ์ํ๋๋ฏ๋ก
4
+ * ์๊ฐ ๋ณต์ก๋๋ O(n * mlogm)
5
+ * ๊ณต๊ฐ ๋ณต์ก๋:
6
+ * Map ํค๋ ์ต๋ ๊ธธ์ด m์ธ ๋ฌธ์์ด strs.length๊ฐ์ด๋ค.
7
+ * ๋ฐ๋ผ์ ๊ณต๊ฐ ๋ณต์ก๋๋ O(n * m)
8
+ */
9
10
+ * @param {string[]} strs
11
+ * @return {string[][]}
12
13
+var groupAnagrams = function(strs) {
14
+ const map = new Map();
15
+ for(const s of strs) {
16
+ const key = s.split('').sort().join('');
17
+ if(!map.has(key)) {
18
+ map.set(key, [])
19
+ }
20
+ map.get(key).push(s);
21
22
+ return Array.from(map.values());
23
+};
0 commit comments