Photo by Ilya Pavlov on Unsplash

Day 2: Delete Node in a Binary Search Tree

Leetcode 75-day challenge

Karan Kumar
The Tech Bible
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:

  1. Search for a node to remove.
  2. If the node is found, delete the node.
notes from iPad

Mainly there are three cases

--

--

Karan Kumar
The Tech Bible

Crazy about snooker, Love Cooking, Passion for Programming and Writing my life 1 word at a time.