Build BST problem

Only 1 test case passed out of 5. Help me identify the mistake in my code.

hey @anuragdeol2017 you are using 2 functions in your main function to build a tree, make a simple BST and then find the answer, implement it like this

Okay, i got it that i am unnecessarily making BST twice. I understood your code.

But i want to know, why exactly is my output wrong?
Am i changing the order of the tree or something else?
Because at the end i am also making a balanced BST.

Hey @anuragdeol2017 sorry for late reply, i was liitle bit busy. Yes you were only missing the order. Rest of your code was right.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.