import java.util.*;
public class Main {
public static int lastIndex(int a[], int n, int m)
{
if(n<=1)
return -1;
int ans;
if(a[n-1]==m)
return (n-1);
else
ans = lastIndex(a, n-1, m);
return ans;
}
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int i,m;
// System.out.println("Enter the length of array");
int n= sc.nextInt();
int a[] = new int[n];
for(i=0; i<a.length; i++)
{
a[i] = sc.nextInt();
}
// System.out.println("Enter the target value");
m = sc.nextInt();
int ans = lastIndex(a,n,m);
System.out.print(ans);
}
}
What is the test case 1? The output is the same but test case 1 is showing error.