← AlgoMindset 75

Delete Node in a BST

Medium🎙 Interview me on this

🧠 Before you code — what pattern fits?

Given a BST root and a key, delete the node with the given key (if it exists) and return the root. The result must remain a valid BST — any valid rebalancing (successor or predecessor replacement) is accepted.

([5,3,6,2,4,null,7], 3) → e.g. [5,4,6,2,null,null,7]

🎬 Video explanation · NeetCodeIO

Your solution runs against 3 unit tests, including edge and large-value cases.

Any valid BST is accepted — the judge checks the sorted order of the remaining values.

Loading...

Test console · 3 unit tests

Submit your code to run it against all 3 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.