I am getting a Runtime error for the above problem with this code
import java.util.Scanner;
class MISSP {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int a[]=new int[100000];
for(int i=0;i<n;i++)
a[sc.nextInt()-1]++;
for(int i=0;i<a.length;i++)
if(a[i]==1)
{System.out.println(i+1);break;}
}
sc.close();
}
}
What is your output if you have three dolls of type 2 2 2
if there are three 2’s then 3 will be stored in the array
so there wont be any output for that case
but you are having a NZEC runtime error
so is import java.util.Scanner enough for the header file
include these header files also
import java.io.;
import java.util.;
still if you are getting a NZEC runtime error use this format (try and catch)
import java.io.;
import java.util.;
public class Main
{
public static void main(String[] args) throws IOException
{
try{
//Your Solve
}catch(Exception e){
return;
}
}
}
Also if you are using IDE , Copy your code from the import statement not from the package statement for the submission