Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent distinct elements. The output order may be arbitrary.

Example:

Input: nums = [1,1,1,2,2,3], k = 2
Output: [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: