Recover Binary Search Tree
MediumLeetCodeAdvanced Trees (BST, LCA, Tree DP)
Approach hintTry it first, then revealHide
An in-order traversal of a valid BST is sorted, so the two swapped nodes appear as one or two inversions. Record the first and last offending nodes during the traversal and swap their values.