Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Delete Node in a BST
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given a root node and a key, delete the node with the given key in the BST.
Sample Input:
[5,3,6,2,4,null,7], 3
Sample Output:
[5,4,6,2,null,null,7]
Hints
Hint 1
Find the node to delete
Hint 2
If node has no children, simply remove it
Hint 3
If node has one child, replace with child
Hint 4
If node has two children, replace with inorder successor
Code Editor
Reset
Run
Save
Loading...