Skip to content
We areTOP 1%

Delete Node in a BST

MediumLeetCodeAdvanced Trees (BST, LCA, Tree DP)
Solve on LeetCode(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Approach hintTry it first, then reveal

Find the key using the BST order. A node with at most one child is replaced by that child; otherwise copy in the in-order successor's value and delete the successor from the right subtree.

More in Advanced Trees (BST, LCA, Tree DP)

Advanced Trees (BST, LCA, Tree DP) questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Lowest Common Ancestor of a Binary Search TreeLeetCodeMedium Solve Lowest Common Ancestor of a Binary Search Tree on LeetCode (opens in a new tab)
2Delete Node in a BSTLeetCodeMedium Solve Delete Node in a BST on LeetCode (opens in a new tab)
3Construct Binary Search Tree from Preorder TraversalLeetCodeMedium Solve Construct Binary Search Tree from Preorder Traversal on LeetCode (opens in a new tab)
4Binary Search Tree IteratorLeetCodeMedium Solve Binary Search Tree Iterator on LeetCode (opens in a new tab)
5Recover Binary Search TreeLeetCodeMedium Solve Recover Binary Search Tree on LeetCode (opens in a new tab)
6House Robber IIILeetCodeMedium Solve House Robber III on LeetCode (opens in a new tab)
7Military ProblemCodeforcesMedium 1600Solve Military Problem on Codeforces (opens in a new tab)
8Infected TreeCodeforcesMedium 1600Solve Infected Tree on Codeforces (opens in a new tab)
9Parsa's Humongous TreeCodeforcesMedium 1600Solve Parsa's Humongous Tree on Codeforces (opens in a new tab)
10Choosing Capital for TreelandCodeforcesMedium 1700Solve Choosing Capital for Treeland on Codeforces (opens in a new tab)
11Distance in TreeCodeforcesHard 1800Solve Distance in Tree on Codeforces (opens in a new tab)
12Maximum White SubtreeCodeforcesHard 1800Solve Maximum White Subtree on Codeforces (opens in a new tab)
13Kth Ancestor of a Tree NodeLeetCodeHard Solve Kth Ancestor of a Tree Node on LeetCode (opens in a new tab)
14Maximum Sum BST in Binary TreeLeetCodeHard Solve Maximum Sum BST in Binary Tree on LeetCode (opens in a new tab)
15Fools and RoadsCodeforcesHard 1900Solve Fools and Roads on Codeforces (opens in a new tab)
16Sum of Distances in TreeLeetCodeHard Solve Sum of Distances in Tree on LeetCode (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account