Merge K Sorted Lists - Divide and Conquer Approach
🡆Merge Two Lists Video: https://www.youtube.com/watch?v=c86I16V8P58
💰 Support me on Patreon: https://www.patreon.com/michaelmuinos
🔗Follow me on Twitter: https://twitter.com/MichaelMuinos
📂Follow me on Github: https://github.com/MichaelMuinos
In this video I go over the popular Leetcode problem Merge K Sorted Lists involving the divide and conquer approach. This solution involves the knowledge of the merge sort algorithm where we must divide our array recursively and merge the lists to sort them at each recursive call. This question is asked at many top tech companies including Amazon, Facebook, Bloomberg, Uber, Adobe, Microsoft, and many more!
At each recursive call, we will compute a midpoint to determine at which point we will split our array. When we split the array into two parts, we will call our recursive function on both the left and right side of the broken array. Our base case is when our start and end index are the same value meaning it is a single linked list. By the end of merging all lists, we should have one final sorted linked list.
The time complexity of the solution will be big O(N * log(K)) where N is the number of nodes we must merge together and K is the number of recursive calls we make to divide the arrays. The space complexity will be big O(log(K)) where K is the number of recursive calls made that fill up our stack space.
Видео Merge K Sorted Lists - Divide and Conquer Approach канала Michael Muinos
💰 Support me on Patreon: https://www.patreon.com/michaelmuinos
🔗Follow me on Twitter: https://twitter.com/MichaelMuinos
📂Follow me on Github: https://github.com/MichaelMuinos
In this video I go over the popular Leetcode problem Merge K Sorted Lists involving the divide and conquer approach. This solution involves the knowledge of the merge sort algorithm where we must divide our array recursively and merge the lists to sort them at each recursive call. This question is asked at many top tech companies including Amazon, Facebook, Bloomberg, Uber, Adobe, Microsoft, and many more!
At each recursive call, we will compute a midpoint to determine at which point we will split our array. When we split the array into two parts, we will call our recursive function on both the left and right side of the broken array. Our base case is when our start and end index are the same value meaning it is a single linked list. By the end of merging all lists, we should have one final sorted linked list.
The time complexity of the solution will be big O(N * log(K)) where N is the number of nodes we must merge together and K is the number of recursive calls we make to divide the arrays. The space complexity will be big O(log(K)) where K is the number of recursive calls made that fill up our stack space.
Видео Merge K Sorted Lists - Divide and Conquer Approach канала Michael Muinos
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Merge K Sorted Arrays - Min Heap Algorithm ("Merge K Sorted Lists" on LeetCode)](https://i.ytimg.com/vi/ptYUCjfNhJY/default.jpg)
![Coding Interview Prep | 3 MUST KNOW Graph Problem Tips](https://i.ytimg.com/vi/tMSdjPKFRD4/default.jpg)
![Minimum Window Substring | Sliding Window | LeetCode](https://i.ytimg.com/vi/U1q16AFcjKs/default.jpg)
![Trie Data Structure Implementation (LeetCode)](https://i.ytimg.com/vi/giiaIofn31A/default.jpg)
![Algorithms Lecture 13: Maximum Sub-array Problem using Divide-and-Conquer](https://i.ytimg.com/vi/yBCzO0FpsVc/default.jpg)
![5 Tips to BEAT the LeetCode Grind](https://i.ytimg.com/vi/qpD0XVH_2So/default.jpg)
![Graph Coding Question - All Paths From Source To Target (LeetCode)](https://i.ytimg.com/vi/CYnvDzMprdc/default.jpg)
![FACEBOOK CODING INTERVIEW QUESTION - MERGE K SORTED LISTS (LeetCode)](https://i.ytimg.com/vi/zLcNwcR6yO4/default.jpg)
![Merge K Sorted Lists - Leetcode 23 - Python](https://i.ytimg.com/vi/q5a5OiGbT6Q/default.jpg)
![Solving Amazon's 2020 Most Asked Interview Question](https://i.ytimg.com/vi/Nj2Bpw1KKds/default.jpg)
![Interview Question: Merge K Sorted Arrays](https://i.ytimg.com/vi/6bvnZzwiKzs/default.jpg)
![Top 10 Algorithms for the Coding Interview (for software engineers)](https://i.ytimg.com/vi/r1MXwyiGi_U/default.jpg)
![Kadane's Algorithm - Maximum Subarray (Dynamic Programming)](https://i.ytimg.com/vi/tmakGVOGV3A/default.jpg)
![Introduction to Linked Lists (Data Structures & Algorithms #5)](https://i.ytimg.com/vi/WwfhLC16bis/default.jpg)
![Longest Increasing Path in a Matrix (DFS + Memoization)](https://i.ytimg.com/vi/uLjO2LUlLN4/default.jpg)
![Merge 2 Sorted Lists - A Fundamental Merge Sort Subroutine ("Merge Two Sorted Lists" on LeetCode)](https://i.ytimg.com/vi/GfRQvf7MB3k/default.jpg)
![Merge K sorted lists | Leetcode #23](https://i.ytimg.com/vi/kpCesr9VXDA/default.jpg)
![LeetCode Explained - Reverse Nodes in K-Groups [HARD]](https://i.ytimg.com/vi/jTWEmztptCQ/default.jpg)
![Airbnb Coding Interview Question - Koko Eating Bananas [LeetCode]](https://i.ytimg.com/vi/Sp2sRLcLND0/default.jpg)
![The 5 String Interview Patterns You Need to Know](https://i.ytimg.com/vi/9clnwaqOU2E/default.jpg)