LeetCode 21: Merge Two Sorted Lists RECURSIVELY - Interview Prep Ep 62

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


⭐ Support my channel and connect with me:

LeetCode 21. Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

Example:
Input: [1,2,4], [1,3,4]
Output: [1,1,2,3,4,4]

Solutions explained (Recursive approach):
1. Two base cases: if l1 == null, we'll just return l2; if l2 == null, we'll just return l1;

Time: O(m + n)
Space: O(m + n)

// TOOLS THAT I USE:

// MY FAVORITE BOOKS:

My ENTIRE Programming Equipment and Computer Science Bookshelf:

And make sure you subscribe to my channel!

Your comments/thoughts/questions/advice will be greatly appreciated!

#softwareengineering #leetcode #algorithms #coding #interview #SDE #SWE #SiliconValley #programming #datastructures
Рекомендации по теме
Комментарии
Автор

Beautiful. When I do it i always worry about the original parameter being erase so I always create a new separate return valuable. Now I can see that is not neccessary and I could've just reuse the parameter for the result. Tks.

bigbigdog
Автор

The walk-through using the stacks and the 2 linked lists as they're being built while the code goes on really helps! Subscribed!

annas
Автор

Thank you so much, 3 years ago, and it still valuable today!!!, I have been stuck trying to visualize this for hours due to the use of .next, your video just give me clarification, thank you thank you and thank you

mirzaarabferuvian
Автор

A very good idea to use different colours to present l1 and l2 in different calls, very helpful!

ИринаПерепелкина-дя
Автор

Thank you so much for dry running the code. It helps to visualise what I am seeing> You are amazing!

VidelShaw
Автор

Oh it's so greate. I'm confused with Recursion and I foud this video. Thank youu

thienminhnguyen
Автор

Wow, thank you. I found your video as my professor said he would quiz us on sorting multiple and this video was super clear. The implementations on what stacks we're being called was helpful as well. Thank you so much. I know this wouldn't work for 3 but for 2 this was extremely easy to understand.

ianvechey
Автор

Thank you so much! I was having trouble understanding the final stack calls and this made it so much better

FullyBR
Автор

After watching more than 5 videos I finally understoon the backtracking from this one. really thankful🥰

muntajir
Автор

So explanatory! Many thanks for your visualizations.

최강재-yc
Автор

You are absolutely awesome man. Thank you!

supax
Автор

Nice and clear .Thank you so much Fisher Coder

abhisheksing
Автор

Guy, great explanation with code and graph!!! thank you, keep going.

chithyFly
Автор

Thank you so much for your clear explanation!

timurradko
Автор

Best Explanation ever❤️❤️❤️❤️. Thank you ❤️❤️

SumanMondal-cbyl
Автор

Excellent and Easy explanation, Thank you so much

wesammustafa
Автор

despite your explanation being clear-cut and easy to understand, it's still somehow a little bit confusing for beginners like me to really grasp the ins and outs of how this code actually works under the hood.

tanhnguyen
Автор

It is so clear explanation thx but i have a one thing that i didnt understand clearly.I just can't understand the returning part after we recall the function how does it work exactly ?

sezermezgil
Автор

Fisher Coder, thank you so much for being such a great explainer and taking the time to do these videos! May you please do an Amazon leetcode series? Have a great day!

TharaMesseroux
Автор

This is the kind of explanation that "gives lemonade seltzer to a heavy stomach" as Koreans have it. Thanks!

ysevanlee