The code provided by pratik bhaiya doesnt work when the tree is not BST
for the input 2 3 7 1 6 8 -1
it shows the tree is BST but it is not BST what modification should be made in the code so that it works for both the condition
Check for BST Problem
You are making a bst through build function so ans will always be yes
But how can we check the tree is not a BST