Wrong Answer Error

I think that the given preorder given in the question is wrong.
Please check my code as well as I am facing this wrong answer error.
My approach was to first sort the given array and then construct the BST. Then I went for preorder.
My Given range function works fine but my preorder is not matching with the given example

i think the formation order of tree is different
according to the qn tree is like
4
/
3 5
/ \
2 6
and accroding to ur code tree will be like
4
/
2 5
\
3 6

there is nothing mentioned about the tree formation.
i have asked this doubt to our senior.
i will get back to u as soon as i got the answer.