Day 2: Delete Node in a Binary Search Tree
Leetcode 75-day challenge
Published in
4 min readFeb 23, 2024
So, the problem I chose to start for the second day is: Delete node in BST
Before I start explaining the solution to this problem, I assume that the reader of this blog has a basic understanding of how Binary Search Trees (BST) work. If not, you can watch my YouTube video on the topic here:
Let’s start:
The problem states that:
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.
The deletion can be divided into two stages:
- Search for a node to remove.
- If the node is found, delete the node.