Top K Frequent Elements

Given a non-empty integer array nums and an integer k, return the k elements with the highest frequencies. Return them in any order. The answer is guaranteed to be unique.

Example 1

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: