leetle

Daily challenge for 2025-09-22

265. Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

Example:
Input: nums = [1,1,1,2,2,3], k = 2
Output: [1,2]

Explanation: 1 appears 3 times, 2 appears 2 times, 3 appears 1 time. The 2 most frequent are [1,2].

Run this challenge interactively in Python or JavaScript when the app loads.