LeetCode – Recover Binary Search Tree (Java)

Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Java Solution Inorder traveral will return values in an increasing order. So if an element is less than its previous element,the previous element is a swapped node. public class Solution { TreeNode first; TreeNode second; TreeNode … Read more