Available question text
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.
Related questions
Continue with questions that share topics or the same question type.
- Balance a Binary Search Tree
Coding
- Binary Search Tree Iterator
Coding
- Binary Search Tree Iterator II
Coding
- Binary Search Tree to Greater Sum Tree
Coding · Binary Search Tree · Binary Tree · Depth-First Search
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Microsoft
Leetcode 99. Recover Binary Search Tree
Interview reported: Jan 17, 2026 · 2 source reports
SENIOR
Source snapshot: Nov 12, 2026
View source