Amazon interview question

Write a function that detects a BST