Please tell why my code is not passing two test cases

your way to create build tree is not correct
you don’t have to build balanced bst
Don’t sort the array

just take the input and insert it into tree