Leetcode 99. Recover Binary Search Tree
Given a BST where exactly two nodes' values were swapped, restore the tree in-place (without changing its structure) so it satisfies the BST property. The core challenge is detecting the two nodes by identifying out-of-order elements in an inorder traversal (straightforward with O(n) space or achievable in O(1) space using Morris traversal) and swapping their values.
Asked at:
Microsoft
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Mid January, 2026
Senior
Early November, 2025
Senior
Hello Interview Premium
Your account is free and you can post anonymously if you choose.