Amazon Interview Question

In a BST we need to find a pair whose sum is equal to a given element x without using map.

Interview Answer

Anonymous

Feb 13, 2023

Inorder traversal will give a sorted array and then apply divide and conquer by addingt he first and last element. If the sum is greater than x then we need to shift the last element and if sum is less than x then we need to shift the first element.