DOUBT in SUM NEQ

i was doing a problem named sum neq of starters 113
my solution for this is
include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin >> t;
while (t–) {
int n;
cin >> n;
vector arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
bool flag = false;
for (int i = 0, j = 1, k = 2, l = 3; i < n - 3; i++, j++, k++, l++) {
if (arr[i] + arr[j] != arr[k] + arr[l]) {
cout << “YES\n”;
flag = true;
break;
}
}
if (!flag) {
cout << “NO\n”;
}
}
return 0;
}

but i am getting wrong anwer can anybody please help me out at which place does my code fails. i have read submissions of other i understood their approach but i cant figure out where my code must be failing. please help anyone.

@mathsdevil
plzz send the problem link.

thanks for showing intent of helping, i figured out what was wrong with my code, i was only considering the consecutive indexes while there could be case when they are not consecutive but still staisfies the condition. iam giving the link of the question for your reference sir Sum Neq Practice Coding Problem - CodeChef

1 Like