My issue
this is failing on 2nd subtask need help
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
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0)
{
int n = sc.nextInt();
long a[] = new long[n];
boolean flag = false;
for(int i=0;i<n;i++)
{
a[i] = sc.nextLong();
}
for(int i=0 , j = n-1;i<n && j>0;i++ , j--)
{
int x = i+1;
int y = j-1;
while(x<y)
{
if((a[i]+a[x])==(a[j]+a[y]))
{
x++;
y--;
}
else
{
flag = true;
break;
}
}
if(flag)
break;
}
if(flag)
System.out.println("yes");
else
System.out.println("no");
}
}
}
Problem Link: Sum Neq Practice Coding Problem - CodeChef