Skip to content

Commit 2c09eef

Browse files
committed
docs: add time and space complexity
1 parent 2e43171 commit 2c09eef

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

group-anagrams/hyogshin.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
"""
2+
풀이 방법
3+
- ord 함수를 이용해서 캐릭터 수를 기준으로 애너그램 구분
4+
- tuple 활용해서 키로 사용
5+
6+
시간 복잡도: O(n * k)
7+
- 중첩 for loop: O(n * k)
8+
9+
공간 복잡도: O(n)
10+
- cnt 문자열: O(1)
11+
- groups dict: O(n)
12+
"""
13+
114
from collections import defaultdict
215
from typing import List
316
class Solution:
@@ -13,3 +26,4 @@ def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
1326
if __name__ == "__main__":
1427
sol = Solution()
1528
print(sol.groupAnagrams(["eat","tea","tan","ate","nat","bat"]))
29+

0 commit comments

Comments
 (0)