Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.