Top K Frequent Elements - Leetcode 347 - Heaps (Python)
Вставка
- Опубліковано 20 жов 2024
- Master Data Structures & Algorithms for FREE at AlgoMap.io/
Code solutions in Python, Java, C++ and JS for this can be found at my GitHub repo here: github.com/gah...
Complete DSA Pathway Zero to Hero: • Data Structures & Algo...
Please check my playlists for free DSA problem solutions:
• Fundamental DSA Theory
• Array & String Questions
• 2 Pointers Questions
• Sliding Window Questions
• Binary Search Questions
• Stack Questions
• Linked List Questions
• Tree Questions
• Heap Questions
• Recursive Backtracking...
• Graph Questions
• Dynamic Programming (D...
My Data Science & ML UA-cam Playlist: • Greg's Path to Become ...
Learn Python and Data Science FASTER at mlnow.ai :)
Support the content: / @greghogg
Follow me on Instagram: / greghogg5
Connect with me on LinkedIn: / greghogg
Follow me on TikTok: / greghogg5
Coursera Plus: imp.i384100.ne...
My Favorite Courses:
Data Structures & Algorithms:
UCalifornia San Diego DSA: imp.i384100.ne...
Stanford Algorithms: imp.i384100.ne...
Python Data Structures: imp.i384100.ne...
Meta Coding Interview Prep: imp.i384100.ne...
Python:
UMichigan Python for Everybody: imp.i384100.ne...
Python Mastery from MLNOW.ai: mlnow.ai/cours...
Google IT Automation w/ Python: imp.i384100.ne...
Web Dev / Full Stack:
Meta Front-End Developer: imp.i384100.ne...
IBM Full Stack Developer: imp.i384100.ne...
Meta Back-End Developer: imp.i384100.ne...
John Hopkins HTML, CSS & JS: imp.i384100.ne...
IBM DevOps: imp.i384100.ne...
Cloud Development:
AWS Fundamentals: imp.i384100.ne...
GCP Cloud Engineer: imp.i384100.ne...
Microsoft Azure Fundamentals: imp.i384100.ne...
Game Development:
Michigan State Unity Development: imp.i384100.ne...
UColorado C++ for Unreal Engine: www.coursera.o...
SQL & Data Science:
SQL by MLNOW.ai: mlnow.ai/cours...
Python for Data Science by MLNOW.ai: mlnow.ai/cours...
Google Data Analytics: imp.i384100.ne...
IBM Data Science: imp.i384100.ne...
IBM Data Engineer: imp.i384100.ne...
Machine Learning & AI:
ML Mastery at MLNOW.ai: mlnow.ai/cours...
ML w/ Andrew Ng: www.coursera.o...
Deep Learning w/ Andrew Ng: imp.i384100.ne...
Master Data Structures & Algorithms For FREE at AlgoMap.io!
The second solution is very creative, thanks for sharing!
I love these heap questions, there's some really interesting solutions
Great work. But if you switch context in the middle, please make sure to complete the context. At 4:32 you were talking about max_heap and in that process it seemed you were explaining the time complexity would be O(Nlogk) but it actually was for min_heap.
Hi, could you please explain why it's O(nlogk) instead of O(klogn)? I don't know why, thank you!
Thank you so much! I have a question that why don't we just use couter.most_common in the heap solution, is it slower than the heap sort?
Good work. Keep going 👍🏼
please help , how come the second solution is not o(n2)
Fantastic!
Thank you for that !
Very welcome :)
This 2nd solution is briliant
It's really cool
2:12, wait, it should've been O(klogn) if we only consider the work of heap
how its o(n) ?we have inner loop
Because there isn't an inner loop?
@@guinea_horn second solution from line 15 to 19 should not it be o(n2) ?
@@samspeaks-hk1vpno, and I'm not sure why you think it is. Unless by n2 you mean 2*n rather than n^2, because we do have two iterations over n items but not an n^2 loop. 2*n reduces to O(n) in typical big o notation
We need more
heappy heap
Heap it up
most_common?