bro gives a "i have no enemies" kinda vibe, chill af
@Chewibub8 ай бұрын
Thank you for this video! Conquered a lot of harder lc problems but this one never really “clicked” for me until I heard your explanation
@60142404 жыл бұрын
Thank you for explaining all the questions in an easy-to-understand manner!
@timc34064 жыл бұрын
Glad it was helpful!
@drakolubez65924 жыл бұрын
thanks man, i searched this for more than 3 hrs
@sharifmansuri6074 жыл бұрын
Sir, you always give very simple solution to complicated problems.. Thanks
@timc34064 жыл бұрын
So nice of you! Thank you :)
@janmichaelaustria6204 жыл бұрын
"Do not trust me, I know nothing". Man, I'm sure gonna miss that bro. Way to finish off the month strong. Tim, your videos have helped so much. I think on the really hard problems I'd look at some of the solutions on leetcode, but then after watching you videos, it all just clicks. I hope you kill it over in SF! Hopefully our paths will cross some day.
@timc34064 жыл бұрын
Lol I'll still solve problems whenever I find the time, it's something I enjoy and need to continue to work on anyway Definitely hope our paths cross!
@Kyou505-b1y3 ай бұрын
this solution is the clearest one I have found
@m.y.m401 Жыл бұрын
if you say "do not trust me, I know nothing", what am I supposed to say??
@vaishaksid75942 жыл бұрын
Why do we set root.left = delete(root.left, key), Why are we setting this to equal to the return value? What's the purpose?
@mukhammadmuratov57152 жыл бұрын
That was such a great explanation, thanks a mill, Timothy! :)
@cyliu24342 жыл бұрын
this solution is creepy. Much better than the leetcode official one
@thejasveejaggi62134 жыл бұрын
Thank you so much sir Im learning the simple way from your code
@leroyjameshopkins5164 Жыл бұрын
Damn, such an elegant solution.
@RBTIT3 жыл бұрын
Root.left= self.deleteNode(root.right,root.val) And If not root.right and root.left : root.left .. In above lines is root.left is same
@timc34063 жыл бұрын
I think so?
@jayantdhingra63 жыл бұрын
Thank You for the explanation. It was pretty helpful !!
@touwmer2 жыл бұрын
Thanks, great solution!
@gicu8ab22 жыл бұрын
I think if you replace lines 18-20 with the following lines the code is a little cleaner and easier to understand: while ptr.left: prev = ptr ptr = ptr.left node.val = ptr.val prev.left = None
@lonnleaf Жыл бұрын
And you introduce a bug, as your code do not work for case where there is no left, additional condition required for your code to work. And when there is recursion everywhere anyway no point to modify code to exclude it, especially it was one line instead of several lines and condition, IMHO.
@tarasrogulya42132 жыл бұрын
Thanks whene you explain its easy
@mustaqode_66178 ай бұрын
Thanks a ton.
@cici-lx6np2 жыл бұрын
I cannot pass the test case with the original code. It works after I change this: ------------- if not root.left and not root.left: return None if not root.left and root.right: return root.right if root.left and not root.right: return root.left ------------- to this: ------------- if not root.right: return root.left if not root.left: return root.right ------------- I don't know the reason tho...
@tonyhe0013 жыл бұрын
Thanks, very clear
@nagendrabommireddi84372 жыл бұрын
thanks a lot sir
@sharifmansuri6074 жыл бұрын
Sir this code doesn't work on edge case like 100 / 70 \80 100 is root, 70 is it's left child and 80 is right child of 70. And if we try to delete 100. As it doesn't enters the recursion that is why happens.
@timc34064 жыл бұрын
It's totally possible I missed something, let me know if you find a fix
@sharifmansuri6074 жыл бұрын
@@timc3406 yes I did find a fix for this.
@olanmalde93124 жыл бұрын
@@sharifmansuri607 , what was the fix?
@MWackodj8884 жыл бұрын
@@sharifmansuri607 What did you do?
@sharifmansuri6074 жыл бұрын
@@MWackodj888 hi kindly find code below please take care of indentation def delete(self,node,val): if node is None: return def preorder_precedor(node): node=node.left while node.right: node=node.right return node.data def preorder_succsor(node): node=node.right while node.left: node=node.left return node .data if valnode.data: if node.right: node.right=self.delete(node.right,val) else: if node.left==None and node.right==None: node=None elif node.left: node.data=preorder_precedor(node) node.left=self.delete(node.left,node.data) else: node.data=preorder_succsor(node) node.right=self.delete(node.right,node.data) return node