What is wrong in this , its working on giving input but on submitting only one test passes , i tried for many inputs , it worked well

import java.util.*;
public class Main {
public static void main(String args[]) {

		int [] primeArray = new int [100];
    int check=0,c=1;
	for(int j=2 ; j<=500 ; j++)
	{
		check=0;
		for(int k=2 ; k<j ; k++)
		{
			if(j%k==0)
			{
				check=0;
				break;
			}
			check=1;
		}

		if(check==1)
		{
			primeArray[c]=j;
			c++;
		}
	}
		


Scanner sc= new Scanner(System.in);
int N=sc.nextInt();
for(int i=1 ; i<= N ; i++)
{
	int a=sc.nextInt();
	int b=sc.nextInt();
	int ans,start=0,end=0;
	if(a<=0) a=1;
	for(int l=0 ; l<primeArray.length ; l++)
	{
		if(a>primeArray[l])
		{
			start=l+1;
		}
		if(b<primeArray[l])
		{
			end=l;
			break;
		}
	}
	
	if(a<3)
	{
		System.out.println(end-start+1);
	}
	else
	{
		System.out.println(end-start);
	}			
}

}

}

Use sieve to solve the problem , your code doesn’t fit in the required time complexity

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.