Untitled

mail@pastecode.io avatar
unknown
java
3 years ago
910 B
2
Indexable
Never
public class Solution {
    public int solve(ArrayList<Integer> A) {
        long oddSums = 0;
        long evenSums = 0;
        int count = 0;
        for (int i = 0; i < A.size(); i++) {
            for (int j = 0; j < i; j++) {
                    oddSums = oddSums + A.get(j);
                    j = j+1;
                    if (j != i) {
                        evenSums = evenSums + A.get(j);
                    }
            }
            for (int j = i + 1; j < A.size(); j++) {
                    evenSums = evenSums + A.get(j);
                    j = j+1;
                    if (j != A.size()) {
                        oddSums = oddSums + A.get(j);
                    }
            }
            if (oddSums == evenSums) {
                count = count+1;
            }

            oddSums = 0;
            evenSums = 0;
        }
        return count;
    }
}