Trim a Binary Search Tree Detailed Solution With Explanation

Hi Everyone, here I have explained the solution of LEETCODE problem “TRIM A BINARY SEARCH TREE” in a simpler way which considers only three cases to approach the answer.
(1) Check if root’s data is strictly greater than upper limit
(2) Check if root’s data is strictly less than the upper limit
(3) Check if root’s data lies with the given range.

Traverse the the tree according to above three cases and you will get the answer easily.
Link to Problem
Link to C++ Code and Explanation

Do Watch it out and subscribe to my Youtube Channel for latest updates.

1 Like