Why my solution is wrong? help me


#1

int Solution::solve(vector &a) {
int se=0,s=0;
for(int i=0;i<a.size();i++){
s=s+a[i];
}
for(int i=0;i<a.size();i+2){
se=se+a[i];
}
int so=s-se;
int r=abs(se-so);
int x=0;
for(int i=0;i<a.size();i++){
if(r==a[i])
x++;
}
return x;
}