Top K Frequent Elements - LeetCode 347 - JavaScript

preview_player
Показать описание


Step by step walk through of the solution to the popular Meta coding interview question, Top K Frequent Elements.

LeetCode 347

JavaScript

0:00 Intro
0:45 Explanation
3:17 Code

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

Impressive how you explained it so well in just 5 mins

thomasl
Автор

Just wanted to add that you may want to move the break statement within the last for loop to the top so we're not pushing an element to our result array for the last iteration where the length of the result array is equal to K. Hope this helps!

sphanish
Автор

awesome! thanks for this, it helped a lot.

Artovon
Автор

I regularly continue to understand nothing but this is not about you, thanks for video

PeriklesPeriklesoglu
Автор

great vid but wondering if using a Map rather than a 'normal' object for your map would make this more performant?

codepeasant
Автор

But isn't bucket sort O(n) in the average case and O(n^2) in the worse case? Wouldn't a heap be more efficiency? Correct me if I'm wrong.

rd_iimpact
Автор

weird. Didn't realize you could add an index item to an empty array like that. Last time I tried this I got caught up trying to initialize the array and it wasn't even necessary!

sawyerburnett
Автор

Do not need to use the set as each element in map will be unique itself

wickedknock