Skip to content

Top K Frequent Element ​

Top K Frequent Element — LeetCode

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

Approach ​

I was on the right track by first counting the numbers, then making a table with the indices being the count and the value being the List of numbers matching the count. Then just reading the table in reverse till K is reached.

Remarks ​

I really struggled with Arrays and Lists in C#