Top K Frequent Elements - LeetCode 347 - Python Solution

preview_player
Показать описание
Today I solve and explain a leetcode algorithm using Python3 called "Top K Frequent Elements"

If you found this helpful Like and Subscribe! I solve LeetCode Algorithms (Python/ Java) and SQL Problems daily!

#leetcode #python #python3 #tutorial #coding #programming
Рекомендации по теме
Комментарии
Автор

What did you think of this question? Comment below a Leetcode question you need help with!! 🙏

codewithcarter
Автор

Just want to clarify, the time complexity is O(klogN) when using a heap. Heapify takes O(n) time, and pushing/popping is O(1).
An O(NlogN) solution would be to rely on sorting to solve the question.

Just wanted to clarify for anyone out there.

Good luck !

business_central
Автор

Very good video, helped me understand exactly what was going on in this problem.

zymzmlc
Автор

Hey. Would you recommend any textbooks for anyone wishing to get better at data structures and algorithms?

mr.plua
Автор

Sorry But what is the point of leetcode or exercising if you still use some library which abstract the solution?

vileni
Автор

why do u use stuff like counter? Have u ever used that in an interview?

wrestlingscience
Автор

Wouldn’t it be more efficient to sort the heap in max to min that way you could pop off k elements. Then you wouldn’t have to pop off the entire stack each time?

toddsjodin