package
Version:
v1.4.8
Opens a new window with list of versions in this module.
Published: Oct 29, 2019
License: MIT
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
< Previous
Next >
Given a non-empty array of integers, return the k most frequent elements.
Example 1:
Input: nums = [1,1,1,2,2,3], k = 2
Output: [1,2]
Example 2:
Input: nums = [1], k = 1
Output: [1]
Note:
- You may assume k is always valid, 1 ≤ k ≤ number of unique elements.
- Your algorithm's time complexity must be better than O(n log n), where n is the array's size.
[Heap]
[Hash Table]
Similar Questions
- Word Frequency (Medium)
- Kth Largest Element in an Array (Medium)
- Sort Characters By Frequency (Medium)
- Split Array into Consecutive Subsequences (Medium)
- Top K Frequent Words (Medium)
- K Closest Points to Origin (Medium)
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.