Amazon interview question

A hard lc BST problem