Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements.

Input format: the first line is the space-separated integer array; the second line is the integer k.

**...

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: