Description:
Solution:
count is the dictionary for heap.
We go through the nums, and counting. If the number doesn't exist, get(0).
And then, from hash table, we put the values in freq[[]] to see how many counts they have.
Since the freq[[]] is descending order, we go through reverse order. We put the highest count to lowest count.
We append the higest number of count in res[]. End the loop if we get the number of k highest value.
Time Complexity: O(n)
Space Complexity: O(n)
'LeetCode ๐๏ธ > Heap' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
295. Find Median from Data Stream (0) | 2023.07.17 |
---|