Skip to content

Commit a380156

Browse files
committed
fix: 리뷰 반영
1 parent c991a2d commit a380156

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

top-k-frequent-elements/Seoya0512.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ def topKFrequent(self, nums: List[int], k: int) -> List[int]:
6161
- 버킷을 뒤에서부터 순회하며 상위 k개 숫자 채우기: O(n)
6262
6363
Space Complexity: O(n)
64-
- freq 딕셔너리와 bucket 리스트로 인해 O(n) 발생
64+
- hash_map 딕셔너리와 bucket 리스트로 인해 O(n) 발생
6565
'''
6666
class Solution:
6767
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
6868
hash_map = {}
6969
for num in nums:
7070
hash_map[num] = hash_map.get(num, 0) + 1
7171

72-
# 인덱스 = 등장 횟수, 값 = 그 횟수만큼 등장한 숫자 리스트
72+
# 예시 nums = [1,6,6,3,2,6,8], bucket = [[1,3,2,8],[],[6]]
7373
bucket = [[] for _ in range(len(nums) + 1)]
7474
for num, count in hash_map.items():
7575
bucket[count].append(num)

0 commit comments

Comments
 (0)