347.Top-K-Frequent-Elements
347. Top K Frequent Elements
题目地址
https://leetcode.com/problems/top-k-frequent-elements/
题目描述
代码
Approach 1: Heap
Complexity Analysis
Time complexity : O(N_log(_k)). The complexity of `Counter method is O(N). To build a heap and output list takes O(N_log(_k)). Hence the overall complexity of the algorithm is O(N+N_log(_k)=O(N_log(_k).
Space complexity : O(N) to store the hash map.
Last updated