validate BST-better solution