일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 715. Range Module
- shiba
- Regular Expression
- Python
- 315. Count of Smaller Numbers After Self
- 파이썬
- DWG
- concurrency
- 컴퓨터의 구조
- 밴픽
- LeetCode
- Generator
- 운영체제
- Class
- Convert Sorted List to Binary Search Tree
- 43. Multiply Strings
- Substring with Concatenation of All Words
- 109. Convert Sorted List to Binary Search Tree
- kaggle
- t1
- iterator
- Protocol
- Decorator
- 프로그래머스
- Python Code
- data science
- attribute
- 30. Substring with Concatenation of All Words
- Python Implementation
- 시바견
Archives
- Today
- Total
Scribbling
LeetCode: 49. Group Anagrams 본문
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
from collections import defaultdict
dic = defaultdict(list)
for s in strs:
counter = [0] * 26
for char in s:
counter[ord(char) - ord('a')] += 1
dic[tuple(counter)].append(s)
return [x for x in dic.values()]
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 31. Next Permutation (0) | 2021.09.09 |
---|---|
35. Search Insert Position (0) | 2021.09.08 |
LeetCode: 41. First Missing Positive (0) | 2021.09.08 |
LeetCode: 47. Permutations II (0) | 2021.09.07 |
LeetCode: 46. Permutations (0) | 2021.09.07 |