Skip to content

Commit c6410bb

Browse files
authored
Create 49-Group-Anagrams.py
1 parent 79a52b1 commit c6410bb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

49-Group-Anagrams.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
3+
ans = collections.defaultdict(list)
4+
5+
for s in strs:
6+
count = [0] * 26
7+
for c in s:
8+
count[ord(c) - ord('a')] += 1
9+
ans[tuple(count)].append(s)
10+
return ans.values()

0 commit comments

Comments
 (0)