We need a starting point when creating a new list. This headnode acts as a sentinel node which is used for temporary purpose and such that we don’t lose track of the starting point.
no, because you are running the first loop only until one of the list reaches null. So it could be possible that l2 reaches null first, while not l1 Then you will jump at the lower portion of code.
we are not creating a new list, we are just assigning pointers. This is the beauty of a linked list. :) Watch my theoretical videos on linked lists for a better understanding.
Just my doubt if anyone can clear will be really helpful , why headNode is never used but at last headNode is returned? it will be having the sorted list??
That is because the initial node we created was a temporary node. So that we have something to start building. The actual merged list starts from the next node. Hence we return the next.
You made it easily understandable with the help of clearly drawing example...Thanks!
best easy explaination ever i searched!
Glad I could help you out :)
great explaination bhaiya keep making such awesome videos for us.
so glad you liked it
Hey, this is giving time limit exceeded on leetcode.. can you please help
Super approach!
best sir jii very good explanations ❤❤
Hi, thank you so much for this explanation. Why the variable headNode never used?
We need a starting point when creating a new list. This headnode acts as a sentinel node which is used for temporary purpose and such that we don’t lose track of the starting point.
@@nikoo28is this python language
no java@@zack176
Excellent Explanation
Glad it was helpful!
Hi Thanks again for the video. The part where appending remaining list if any one ofthem reach to null, doesn't that code become unreachable?
no, because you are running the first loop only until one of the list reaches null. So it could be possible that l2 reaches null first, while not l1
Then you will jump at the lower portion of code.
NICE SUPER EXCELLENT MOTIVATED
great explaination bhaiya
this was the best man .....
Thanks. Keep doing the good work
sir but we are creating a new list doesn't it consumes extra space
we are not creating a new list, we are just assigning pointers. This is the beauty of a linked list. :) Watch my theoretical videos on linked lists for a better understanding.
Nikhil, Can you please do a video on Merge K Sorted List?
Yes, I plan to do it, it will be very similar to this approach though
@@nikoo28 Thank you!
Just my doubt if anyone can clear will be really helpful , why headNode is never used but at last headNode is returned?
it will be having the sorted list??
Because we are playing with pointers. Watch my introductory videos on linked lists for a better understanding :)
NIcely Done!
thanks brother!!
returnNode = returnNode.next code line is not explained. Can you please.
That is because the initial node we created was a temporary node. So that we have something to start building.
The actual merged list starts from the next node.
Hence we return the next.
@@nikoo28 how is it constant space? are not we storing them in returnNode? so it should be O(n + m) space and time also???
Sir, could you please do lectures on Python data structures
what data structures are you looking for?
@@nikoo28 stacks,queues,linked lists,hash maps,collection frameworks
Thanks
great job
Bhaiya thanku 😊
It results in a runtime error
Why are we assigning the dummy node to another node??
We need a starting point for our result. This dummy node serves the purpose.
Sir, it is saying time limit exceeded
yes and also it s giving :
java.lang.NullPointerException: Cannot read field "val" because "" is null
this error can u tell. me why?:
did you check out the code on github given in the video description?
What is the last line tell me🤧🤧🤧🤧🤬
man why have u made this video when u did not explain each line.
Which part are you facing a problem at? I can help you out further.
@@nikoo2805 last line
chup reh
we understood bro