I am not able to pass test case 0 in this ques , I have used soe also and all my rest cases are working.
Can somebody tell me whats the problem?
public class Main {
static int num = 0;
static boolean primes[] = new boolean [1000000];
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
soe(999999);
while(t-- > 0){
num = sc.nextInt();
if(num == 1)
{
System.out.println("2");
continue;
}
giveprime(num);
}
}
public static void soe(int n){
for(int i=0;i<n;i++){
primes[i] = true;
}
int n2test =2;
while(n2test*n2test <= n){
if(primes[n2test]){
for(int i=2;i*n2test <= n;i++ ){
primes[i*n2test] = false;
}
}
n2test++;
}
}
public static void giveprime(int num){
int count=0;
for(int i=2;i<= 1000000;i++){
if(primes[i]==true){
count++;
if(count == num){
System.out.println(i);
break;
}
}
}
}
}