Incorrect output

In this problem we only need to input n (number of elements in the arr).The preorder array and the inorder array. You are initializing t and doing t-- without taking it as input, thought it is not mentioned anywhere in the problem to take t ,key, k as input. You are doing it for what??? i have modified your code you can refer to it https://ide.codingblocks.com/s/249657

That was a wrong link for the problem. This is the updated link https://ide.codingblocks.com/s/249664

Dry run your code for the input :
15
12 10 17 22 20 85 74 38 23 64 46 51 65 99 87
10 12 17 20 22 23 38 46 51 64 65 74 85 87 99
Desired output: 15
Output given by your code : 1
you will get why you are getting incorrect output