Build tree from preorder and postorder

Here i am not udersatnding how it taken care of node which has already became leaf node

When you reach a leaf node, there is no element/node in the right subtree and in the left subtree. So nothing can be inserted to its left and right. Do a dry run with any sample case and check it yourself. You will understand it better.

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.