Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit bf35809

Browse files
Update and rename top_k_frequent_heap.py to top_k_frequent.py
1 parent e7d1950 commit bf35809

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

heaps/top_k_frequent.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
# author: bt3gl
4+
5+
6+
def top_k_frequent_values(list, k):
7+
8+
if k == len(nums):
9+
return nums
10+
11+
# hashmap element: frequency
12+
counter = Counter(nums)
13+
return heapq.nlargest(k, counter.keys(), key=counter.get)

heaps/top_k_frequent_heap.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)