← Microsoft questions

Restore Swapped BST and Closest Pair in Sorted Array

Filed under Microsoft

Two elements of a Binary Search Tree (BST) are swapped by mistake. Recover the tree without changing its structure. Also, find a pair of elements in a sorted array whose sum is closest to a given…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Microsoft questions

Collected from public candidate posts and coding forums. Updated Nov 2026.