Welcome to the daily solving of our PROBLEM OF THE DAY with Shivam Sinha We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Binary Search Tree but also build up problem-solving skills.
Given two BSTs, return elements of merged BSTs in sorted form.
Examples :
Input: BST1: 5 / \ 3 6 / \ 2 4 BST2: 2 / \ 1 3 \ 7 / 6 Output: 1 2 2 3 3 4 5 6 6 7 Explanation: After merging and sorting the two BST we get 1 2 2 3 3 4 5 6 6 7.
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/merge-two-bst-s/1