450. Delete Node in a BST
Problem Statement
Given 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.
Basically, the deletion can be divided into two stages:
Search for a node to remove.
If the node is found, delete the node.
Example 1:
Example 2:
Example 3:
Constraints:
The number of nodes in the tree is in the range
[0, 104]
.-105 <= Node.val <= 105
Each node has a unique value.
root
is a valid binary search tree.-105 <= key <= 105
Intuition
Links
https://leetcode.com/problems/delete-node-in-a-bst/description/
Video Links
https://www.youtube.com/watch?v=kouxiP_H5WE&ab_channel=takeUforward
Approach 1:
C++
Approach 2:
C++
Approach 3:
C++
Approach 4:
C++
Similar Problems
Last updated