deleteNodeInBST.js

@@ -1,19 +1,719 @@
-d
+D
 elete
+ 
 Node
-InBST.js
+ in a BST%0A%0AGiven a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.%0A%0ABasically, the deletion can be divided into two stages:%0A%0ASearch for a node to remove.%0AIf the node is found, delete the node.%0ANote: Time complexity should be O(height of tree).%0A%0AExample:%0A%0Aroot = %5B5,3,6,2,4,null,7%5D%0Akey = 3%0A%0A    5%0A   / %5C%0A  3   6%0A / %5C   %5C%0A2   4   7%0A%0AGiven key to delete is 3. So we find the node with value 3 and delete it.%0A%0AOne valid answer is %5B5,4,6,2,null,null,7%5D, shown in the following BST.%0A%0A    5%0A   / %5C%0A  4   6%0A /     %5C%0A2       7%0A%0AAnother valid answer is %5B5,2,6,null,4,null,7%5D.%0A%0A    5%0A   / %5C%0A  2   6%0A   %5C   %5C%0A    4   7
 %0A

add desc