loved the explanation i've watched other videos where they created a new list and just added the values in sorted order changing the pointers is what was asked here Thank you very much
a issue which might be either me or bcom someone elses problem in ur c++ solution : correc the dummy node initialization ListNode*dummy = new ListNode(0) , this works everytime and doesnt produces error
What would a solution look like if we were asked to create a new node and then add it to our linked list? I am trying to implement that but i am struggling
def mergeTwoLists(self, list1, list2): cur1, cur2 = list1, list2 # dummy node cur3 = l3 = ListNode() while(cur1 and cur2): # link current (of result list) to the new node cur3.next = ListNode() # move current to the new node cur3 = cur3.next # compare values if (cur1.val
Hi Greg, thanks again for the nice explanation. However, I cannot fully understand this: d = cur cur.next = list1 cur = list1 Why the same time list1. Do you have some basics elsewhere?
Thank you for the explanation. Very clear and neat. I'm a python-virgin and have two trivial questions 1. how do you test the code? I've written a code and test it on leetcode and it's fine but when running on python, I can't test it and got error! 2. Why do you insert # behind ListNode class? if it is excluded from the code how does the remaining part of the code work?
Master Data Structures & Algorithms For FREE at AlgoMap.io!
This is the only explanation that makes sense, I prefer this over the neetcode video.
Glad to hear it!!
Neetcode sucks man . I get bored watching his videos
Very clean solution, thanks a lot!
Thank you!
your videos are always so clear and helpful! thank you!
Thank you so much.This was really easy to understand.
loved the explanation
i've watched other videos where they created a new list and just added the values in sorted order
changing the pointers is what was asked here
Thank you very much
No problem!
really good explanation bro!
can't thank you enough gregg !!!!
thanks greg, i was not able to understand how its O(1) space until i saw your whiteboarding
can u explain me who it is o(1) im also confused
HOW IS THAT AN EASY QUESTION
a issue which might be either me or bcom someone elses problem
in ur c++ solution : correc the dummy node initialization ListNode*dummy = new ListNode(0) , this works everytime and doesnt produces error
You made it easy to understand. Nicely explained.
Glad to hear it!
What would a solution look like if we were asked to create a new node and then add it to our linked list? I am trying to implement that but i am struggling
def mergeTwoLists(self, list1, list2):
cur1, cur2 = list1, list2
# dummy node
cur3 = l3 = ListNode()
while(cur1 and cur2):
# link current (of result list) to the new node
cur3.next = ListNode()
# move current to the new node
cur3 = cur3.next
# compare values
if (cur1.val
Really clear explanation, thank you so much! keep up the good work
Very glad to hear it! Thanks so much :)
Hi Greg, thanks again for the nice explanation. However, I cannot fully understand this:
d = cur
cur.next = list1
cur = list1
Why the same time list1. Do you have some basics elsewhere?
Love the explanation
Thank you for the explanation. Very clear and neat. I'm a python-virgin and have two trivial questions
1. how do you test the code? I've written a code and test it on leetcode and it's fine but when running on python, I can't test it and got error!
2. Why do you insert # behind ListNode class? if it is excluded from the code how does the remaining part of the code work?
Good question. Basically leetcode puts the class in a hashtag for readability. But the class is actually necessary. It's leetcode being weird
Helpful :)
i am getting tle error
Crisp and clear
Super glad to hear it!!
MergeSort, essentially.