question :- Log In | HackerEarth
answer :-
public static void main(String args[] ) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int ctr=0;
int t=Integer.parseInt(br.readLine());
for(int i=0;i<t;i++)
{
int n=Integer.parseInt(br.readLine());
String input[]=(br.readLine()).split(" ");
for(int j=0;j<n;)
{
if(Integer.parseInt(input[j]) == ++j)
{
ctr++;
}
}
if(ctr==n)
{
System.out.println("inverse");
}
else
{
System.out.println("not inverse");
}
ctr=0;
}
}
}
Though too trivial, the solution is shown correct when i compile and run, but on submitting, it gives WA.