while submitting it is showing no output… is my solution correct? And how will i add the condition for (-1 -1) ?
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
int i;
for(i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
int t=sc.nextInt();
for(i=0;i<t;i++)
{
int ser=sc.nextInt();
int findex=0;
for(int j=0;j<n;j++)
{
if(a[j] == ser)
{
System.out.print(j+ " ");
}
break;
}
for(int k=n-1;k>0;k--)
{
if(a[k]== ser)
{
System.out.print(k+ " ");
}
break;
}
}
}
}