Challenge: Delete Node

Let’s delete a node in a BST.

Problem

Remove the node x from a BST and reorganize nodes of the BST to maintain its necessary properties.

Input

A value x that needs to be deleted.

Output

The DeleteNode() function will simply delete the node.

Sample input

4

Sample output

Let’s suppose we have the following tree:

Get hands-on with 1400+ tech skills courses.