Doubt in building tree

will the input be always in sorted order

Hello @Abhay-Chauhan-1546158815521966 as it is given that the inorder traversal will be given in the input format and inorder traversal is always sorted.

i used this approach is there any optimised approach

i was able to change the values of right subtree but for left subtree i did not got the approach

@Abhay-Chauhan-1546158815521966 form the tree in this way:

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.