sir plz once look at my code,one of my test case is not getting absolutely coorect…i m getting a mst lyk,my this code is quiet slow to compute for one test case.
import java.util.Scanner;
public class Main{
static Scanner s=new Scanner(System.in);
public static void main(String args[]) {
int n=s.nextInt();
// if(n>0 && n<=10000) {
int[] arr=new int[n];
for(int j=0;j<n;j++) {
arr[j]=s.nextInt();
}
for(int j=0;j<n;j++) {
int res=0, p=2;
while(arr[j]!=res){
int count=0;
if(p==2) {
res++;
p++;
continue;
}else if(p%2 == 0) {
p++;
continue;
}else {
boolean flag =true;
for(int l=3;l<=Math.sqrt(p)+1 ; l+=2) {
if(p%l == 0) {
flag=false;
p++;
// break;
}
}
if(flag) {
res++;
p++;
}
}
}
System.out.println(p-1);
}
}
}
//}