Top K Frequent Elements

Asked at Uber · Coding Questions · Difficulty: Easy · Last asked Jan 10, 2026

Given an integer array `nums` and an integer `k`, return the `k` most frequent elements in the array. The test cases are generated such that the answer is always unique. You may return the output in any order.

Loading the problem…