Complete the code to check if the current node is null before deletion.
if (root == [1]) return root;
We check if the root is null to stop recursion when the node is not found.
Complete the code to move left or right in the BST during deletion.
if (key < root.val) root.left = DeleteNode(root.left, [1]); else if (key > root.val) root.right = DeleteNode(root.right, [1]);
We pass the key to continue searching for the node to delete.
Fix the error in finding the minimum node in the right subtree.
TreeNode minNode = root.right; while (minNode.[1] != null) minNode = minNode.left;
To find the minimum node in the right subtree, we go left until no more left child exists.
Fill both blanks to replace the node's value and delete the minimum node.
root.val = minNode.[1]; root.right = DeleteNode(root.right, minNode.[2]);
We replace the root's value with the minimum node's value, then delete that minimum node by its value.
Fill the blanks to handle deletion when node has one or no child.
if (root.left == null) return root.[1]; else if (root.right == null) return root.[2]; return root;
If left child is null, return right child to replace node; if right child is null, return left child. The last return is the original root.
