This earned a subscriber, ive been really struggling with this problem, appreciate your effort.
@anasbhih51149 ай бұрын
Thank you so much! i finally found a well explained video
@MohammedAhmedIsAwesome2 жыл бұрын
Fantastic explanation, thank you!!
@tabmax222 жыл бұрын
I don't understand the cur = dummy business. At the end when you print dummy, why does that not print cur?
@sanjaykj4818 Жыл бұрын
Thanks man appreciate your effort
@ayeshaarifkhawaja-nz4xt Жыл бұрын
Awesome explanation, thank you
@rouzbehtalebi Жыл бұрын
Nice Explanation 👍
@cecepskj6948 Жыл бұрын
how did the program know that we only took the first initial value of l1 or l2? why don't we just code like this: curr.next = l2.val ?? Ty in advance
@manpt1232 жыл бұрын
what a explanation bro. sub done. carry on
@tigerior3 жыл бұрын
Cool stuff! Thank you!
@viktorsk82022 жыл бұрын
Thanks bro, you so kind!
@srikumarma Жыл бұрын
Hey, thx for the explanation but in leetcode when i run the code i am getting run time limit exceeded
@sumeyyesalman47193 жыл бұрын
Thank you, a very nice explanation!
@eugenioforever36772 жыл бұрын
I have not found a video that explains line 6 and 7 of the code.
@Fetdude2 жыл бұрын
I have a question: How do I print the linked list that dummy.next produces? Ty in advance
@imbesrs2 жыл бұрын
You'd have to iterate over the entire linked list. Its the one downside of linked list. class node: def __init__(self, data=None): self.data = data self.next = None def display(self): elems = [ ] cur_node = self while cur_node.next != None: cur_node = cur_node.next elems.append(cur_node.data) print(elems) This method you add them all to an array and print the array. You could also do string concatenation or print at the end of each while loop iteration
@Fetdude2 жыл бұрын
@@imbesrs you sound like a stackoverflow hero
@imbesrs2 жыл бұрын
@@Fetdude I appreciate that but im very new to coding as well. Just now learning about linked list so the knowledge wsa fresh in my head. Cheers!
@neerajkumar812 жыл бұрын
@@imbesrs `elems` here is a flat list, the problem needs a linked list to be output. Meaning, you need to manage the next pointers appropriately in the final result.
@imbesrs2 жыл бұрын
@@neerajkumar81 The person I replied to wanted to know how to print the output. I was not answering the original leetcode question
@afsharali1279 Жыл бұрын
For me with the same code, Test case1 failed
@parthshah15633 жыл бұрын
I have one question:- Initially the Dummy node is pointing to the head node (I got it) but which head node? Head node of L1 or head node of L2?
@AbhishekSharma-vb9ux2 жыл бұрын
I think dummy node is an independent node with val=0 and next = none. It doesnt point to any head initially, and after the first comparison, it points to '1'.
@shashankl85892 жыл бұрын
initially dummynode is pointing to None,then with the condition it will point to head of l1 or l2
@HarshPatel-iy5qe10 ай бұрын
Consider dummy node is pointing to output linked-list
@Rustincohle88 Жыл бұрын
Why ListNode() is used in Sol
@ishayadav0013 жыл бұрын
👏🏽👏🏽👏🏽
@tanishasethi73633 жыл бұрын
Tysm 😭
@ahmedanwer68992 жыл бұрын
pulling my hair because of this why does the following for the while loop part not work? why do i need the else statement? while list1 and list2: if list1.val > list2.val: print(list2.val) tail.next = list2 list2 = list2.next if list1.val
@maamounhajnajeeb2092 жыл бұрын
youshould put (if then elif) not (two if)
@mahir75303 жыл бұрын
why do we return dummy?
@ngochainguyen912 жыл бұрын
same Question :))
@neerajkumar812 жыл бұрын
Initially dummy points to curr. But, later in the loop - curr moved on to create the resultant list. Finally, dummy still points to an address which was held by curr at the very beginning. So, while returning dummy, we are making sure, dummy gets the head pointer of the resultant list.