Find Top K Most Frequent Elements | Java Code | Programming Tutorials

preview_player
Показать описание
Given a non-empty array of integers, find the top k most frequent elements. In this tutorial, I have explained the algorithm and it's java code to find top k frequent elements.

Рекомендации по теме
Комментарии
Автор

I've seen this solution before but I had trouble understanding it, it's clear to me now thanks to your explanation. Thank you!

Vicbomlen
Автор

That's a great solution. Thank you sir

basmam.mostafa
Автор

great Video man !!
But just a doubt, if we take array as {1, 1, 1, 2, 2, 3, 3, 3, 4, 4} and k=3 the answer turns out to be 1, 3, 2, 4 but we need only 3 elements. How could that be solved.?

aishwaryaraman
Автор

are you taking care of duplicates in your list?

purnimavijaya
Автор

Thank you! what is the runtime of this solution?

maymerari
Автор

hey just curious, i have tried this solution on leetcode, but runtime is 48ms, 0%tile y so?

evarryl
Автор

I am not getting why u have done k=k-list.sie pl help me out

yadnyeshrane
Автор

the bucket takes too much space. it is not a good solution.

maxqin