0099. Recover Binary Search Tree
https://leetcode.com/problems/recover-binary-search-tree
Description
You are given the root of a binary search tree (BST), where the values of exactly two nodes of the tree were swapped by mistake. Recover the tree without changing its structure.
Example 1:

Example 2:

Constraints:
The number of nodes in the tree is in the range
[2, 1000].-231 <= Node.val <= 231 - 1
Follow up: A solution using O(n) space is pretty straight-forward. Could you devise a constant O(1) space solution?
ac
Last updated
Was this helpful?