My issue
time limit exceeded… on my question Two pointers -Difference Pairs
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
while(T-->0)
{
int N=sc.nextInt();
int B=sc.nextInt();
int[]A=new int[N];
for(int i=0;i<N;i++)
{
A[i]=sc.nextInt();
}
Arrays.sort(A);
int count=0;
for(int i=0;i<N;i++)
{
for(int j=i+1;j<N;j++)
{
if((long)Math.abs(A[i]-A[j])==B)
{
count=1;
break;
}
}
}
System.out.println(count);
}
}
}
Learning course: Two pointers
Problem Link: CodeChef: Practical coding for everyone