L23. Merge two sorted Linked Lists
Vložit
- čas přidán 30. 12. 2023
- Problem Link: bit.ly/3vjuaGQ
Entire LL Sheet: takeuforward.org/linked-list/...
Check our A2Z DSA Course: takeuforward.org/strivers-a2z...
Please do give us a like, and subscribe to us if you are new to our channel.
Do follow us on our socials: linktr.ee/takeuforward
Bro woke up and dropped the whole playlist
Turu
Definittely this is one of the best playlist on linked list in youtube.
best series i have ever seen especially the dry run thank u so much for an exceptional series
Byfar the best linked list series
Thank you very much Raj Bhaiya
we missed youuu here ! KEEP UP THE GREAT WORK YOU'RE DOIN MAN
Bhaiya ,I can definitely say, you are god of DSA❤❤
Great video, -->
This video is not updated in the SDE sheet and in the Article as well.
amazing explanation ✨✨
Epic bhaiya!!
Thanks ... nice explaination
Very good explanation. 😊😊
Welcome Back sir❤🎉
To be exact, time complexity would be O(min(n1 + n2)).
Thanks Striver!!1
Nice explanation ❤
Understood✅🔥🔥
Best bhai Thank you
Thanks
Understood!
Understoood
Bhaiya when can we expect stack queue playlist
Happy New Year 🎉
Thanks for clean code. sudo code have minor issue , please correct it . if ( t1 -> data < t2 -> data ) You missed equal elements . it should be if ( t1 -> data data )
yes. I wondered the same. I came here from leetcode. there some values in the two sorted lists which are same. but what an explanation. I know only basics of linked lists. I was able to undersand well enough
There is no need for this Equal to condition bcz it already handled by else part
But it is good to think about this condition👍👍
@@ujjwalsingh6889 yes. I realized it later. when I did a dry run. Thanks for replying ujjwal
@@anirudhv0062 You need to improve your DSA These are basics
meri tarf se ik papii supper good explanation
🏳️🌈
On which topic you will be making your next playlist??
why this problem is not in the A2Z sheet?
Understood
understood
Nyc
What if I use a multiset instead of an array in brute force approach??
Awesome 😎 17:36
Can't we use dummy node to make it as a copy of the lowest head value of either of the lists (which acts as the head of the new merged list) , and repeat the same process . Will the solution be different ?
Undertsood
shouldn't time complexity be min(n1,n2) coz this is where while stops and then it's just one extra link that we've to do?
if the smaller values were in the n2 then in this case we will traverse till the end of n2. so min(n1,n2) will not work.
I couldn't find this question in the a2z playlist.
class Solution {
public ListNode mergeTwoShortedLists(ListNode l1,ListNode l2){
ListNode ans=new ListNode(-1);
ListNode temp=ans;
while(l1!=null&&l2!=null){
if(l1.val
I'm confused how the space complexity is O(1)? We are creating a dummy node which extends to hold the nodes of both linked list 1 and linked list 2. Don't the space complexity be O(n1+n2) where n1 are number of nodes in linked list 1 and n2 are number of nodes in linked list 2.
ACTUALLY ITS LIKE VARIABLE DECLARATION .
8:15 Can anyone tell in which video dummy node concrpt is explained by him😅
god
Done and dusted😅
God or what
UnderStood
There's a little mistake at the end for handling remaining nodes after either one list has reached null, there should be a another while loop to handle those cases. Also there isn't a java code to the above problem kindly provide one
No need for while loop , see the video 11:40
No,we don't need the while loop here. As we are using the exiting nodes itself,not creating new ones. Suppose n1 is null, so n2 is left. we pointed temp->next as n2. so, from here, link is maintained up to n2 becomes null. Hope you got this.
Wait what 😂 he did solved that with if else. Watch it completely before commenting.
free(dummy node):
us
where the hell is the dummy node concept been spending hours to find but couldn't find it Someone plz pin it
mila?
Understood!
Understood