Amazon interview question

Code to check if a tree is BST.