Skip to content

Commit 488a909

Browse files
committed
feat: Add solution for LeetCode problem 49
1 parent 183f9b1 commit 488a909

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

group-anagrams/WhiteHyun.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// 49. Group Anagrams
3+
// https://leetcode.com/problems/group-anagrams/description/
4+
// Dale-Study
5+
//
6+
// Created by WhiteHyun on 2024/05/19.
7+
//
8+
9+
final class Solution {
10+
func groupAnagrams(_ strs: [String]) -> [[String]] {
11+
var dictionary: [String: [String]] = [:]
12+
for str in strs {
13+
dictionary[String(str.sorted()), default: []].append(str)
14+
}
15+
16+
return Array(dictionary.values)
17+
}
18+
}

0 commit comments

Comments
 (0)