why do i get segmentation error
Construct Tree from given Inorder and Preorder traversals
@khushipriya681
You are trying this code for multiple testcases and using static variable i.
While it will work perfectly for a single testcase , the variable would retain its previous memory from the previous testcase and ruin the following testcases.
I would suggest you to use a global variable instead of static and initialising it to 0 for every testcase iteration.