Hello guys,
Here’s the problem’s link.
Here’s my code in java
import java.util.*;
class ChefandDolls
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
int T=in.nextInt();
while(T-- > 0)
{
int N=in.nextInt();
int[] Ns=new int[N];
for(int i=0 ; i<N ; i++)
Ns[i]=in.nextInt();
Arrays.sort(Ns);
for(int i=0 ; i<N ; i+=2)
{
try
{
if(Ns[i]!=Ns[i+1])
{
System.out.println(Ns[i]);
return;
}
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(Ns[i]);
}
}
}
}
}
But this code get WA, for some reason that I badly want to know
Please Help!