What do we have to do in this ques?

What do we have to do in this ques?

hello @haseebshaik00

u r given a preorder traversal of the tree, but if u build tree just by using preorder then it might result in skewed tree (build will take O(n^2) ) .

so basically u need to use some other approach to build bst that takes less time than this trival one.

after making the balanced bst should it’s preorder traversal be same as the given input?

yeah it should be . . …

@haseebshaik00

also tree is not mandatory to be a balanced one.
thr constraint is on ur build function it should be optimal (take less time than trivial one).

can you please share the code i dont know how to approach

@haseebshaik00
pls refer method 2 of this article->link

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.