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 df66dc6 commit 6a35335Copy full SHA for 6a35335
1 file changed
group-anagrams/soobing2.ts
@@ -0,0 +1,20 @@
1
+/**
2
+ * 문제 유형
3
+ * - String
4
+ *
5
+ * 문제 설명
6
+ * - 애너그램 그룹화
7
8
+ * 아이디어
9
+ * 1) 각 문자열을 정렬하여 키로 사용하고 그 키에 해당하는 문자열 배열을 만들어 리턴
10
11
+ */
12
+function groupAnagrams(strs: string[]): string[][] {
13
+ const map = new Map<string, string[]>();
14
+
15
+ for (let i = 0; i < strs.length; i++) {
16
+ const key = strs[i].split("").sort().join("");
17
+ map.set(key, [...(map.get(key) ?? []), strs[i]]);
18
+ }
19
+ return [...map.values()];
20
+}
0 commit comments