FastPrepDelete Node in a BST
Problems/Delete Node in a BST

Delete Node in a BST

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a first-hand Bloomberg new-grad phone interview through the standard Delete Node in a BST problem.

You are given the root of a binary search tree and an integer key. Delete the node whose value equals key, if it exists, and return the updated root.

The returned tree must remain a binary search tree. When the deleted node has two children, replace its value with the smallest value in its right subtree, then delete that successor node. Always use this rule, so every correct solution returns the same tree.

Function

deleteNode(root: TreeNode, key: int) → TreeNode

Examples

Example 1

root = [5,3,6,2,4,null,7]key = 3return = [5,4,6,2,null,null,7]
root
532467
Removed
→
return
54267
Moved or new

Node 3 has two children. Its inorder successor is 4, which takes its place.

Example 2

root = [5,3,6,2,4,null,7]key = 0return = [5,3,6,2,4,null,7]
root
532467
→
return
532467

The key is absent, so the tree is unchanged.

Example 3

root = []key = 0return = []
root
empty
return
empty

An empty tree remains empty.

Constraints

  • The tree contains between 0 and 10000 nodes.
  • -100000 <= Node.val <= 100000.
  • Every node value is unique and the input is a valid binary search tree.
  • -100000 <= key <= 100000.

More Bloomberg LP Phone Screen questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • AVL Insertion and RotationsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Delete Node in a BSTTokopedia · PHONE SCREENTokopedia interview questions
  • Convert a Sorted Linked List to a Balanced BSTMeta · PHONE SCREENMeta interview questions
  • Binary Tree Target-Sum PathsByteDance · PHONE SCREENByteDance interview questions
  • Top K Pins with Insert and QueryPinterest · PHONE SCREENPinterest interview questions
  • Maximum Root-to-Leaf and Leaf-to-Leaf Path SumsAmazon · ONSITE INTERVIEW
  • Path Between Two Nodes of a Fibonacci TreeDatabricks · ONSITE INTERVIEWDatabricks interview questions
  • Insert into a Left-Complete Binary TreeRubrik · ONSITE INTERVIEWRubrik interview questions
  • Kth Closest Element in a BSTLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Construct a Binary Tree from Preorder and InordereBay · PHONE SCREENeBay interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    public TreeNode deleteNode(TreeNode root, int key) {
        // Write your code here.
    }
}
Checking account…