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
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
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
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
your videos are always so clear and helpful! thank you!
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
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!
can't thank you enough gregg !!!!
really good explanation bro!
Very clean solution, thanks a lot!
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
You made it easy to understand. Nicely explained.
Glad to hear it!
Really clear explanation, thank you so much! keep up the good work
Very glad to hear it! Thanks so much :)
Love the explanation
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
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
HOW IS THAT AN EASY QUESTION
i am getting tle error
Crisp and clear
Super glad to hear it!!
MergeSort, essentially.