csweekly.xyz

Weekly coding problems and projects brought to you by the Southern Connecticut State University Computer Science Club

Week #1 DSA

Top K Frequent Elements

Given an integer array 'nums' and an integer 'k', return the k most frequent elements within the array. The test cases are generated such that the answer is always unique. You may return the output in any order. Example 1: Input: nums = [1,2,2,3,3,3], k = 2 Output: [2,3] Example 2: Input: nums = [7,7], k = 1 Output: [7]

Medium

02-12-2025 05:02 PM

Posted by Mustafa Bolat