Build tree from postorder ansd inorder

i have made this code for building a tree from the postorder and inorder but this code is not giving the right output
plz make the required changes

hello @Nishant_08

what is correct output for ur given test case?

1
2 5
3 4 6
8 7
but i am getting this


and on ide i am getting
3
1
2 5
4 6
8 7

image

it should be i=n-1