[LeetCode][Python3] 49. Group Anagrams
2018. 11. 14. 01:31 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/group-anagrams
My Solution :
class Solution:
def groupAnagrams(self, strs):
"""
:type strs: List[str]
:rtype: List[List[str]]
"""
counter = {}
for item in strs:
key = [0]*26
for c in item:
key[ord(c)-97] += 1
counter.setdefault(tuple(key), []).append(item)
return list(counter.values())
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 347. Top K Frequent Elements (0) | 2019.01.05 |
---|---|
[LeetCode][Python3] 94. Binary Tree Inorder Traversal (1) | 2019.01.03 |
[LeetCode][Python3] 62. Unique Paths (6) | 2018.11.15 |
[LeetCode][Python3] 55. Jump Game (0) | 2018.11.15 |
[LeetCode][Python3] 48. Rotate Image (0) | 2018.11.13 |
[LeetCode][Python3] 46. Permutations (0) | 2018.11.12 |
[LeetCode][Python3] 36. Valid Sudoku (0) | 2018.11.11 |
[LeetCode][Python3] 34. Find First and Last Position of Element in Sorted Array (0) | 2018.11.11 |
최근에 달린 댓글 최근에 달린 댓글