R9-found at last


why is one test case showing time limit

Your code needs these changes,
if(curr_index==N)
{
return -1;
}
long long int index=foundlast(ar,curr_index+1,N,M);
if(index==-1 && ar[curr_index]==M)
{
return curr_index;
}
else
{
return index;
}