How can the following simple implementation of sum be faster?
sum
private long sum( int [] a, int begin, int end ) { if( a == null ) { ret
I have scored 100% for this one:
int equi (int[] A) { if (A == null) return -1; long sum0 = 0, sum1 = 0; for (int i = 0; i < A.Length; i++) sum0 += A[i]; for (int i = 0; i < A.Length; i++) { sum0 -= A[i]; if (i > 0) { sum1 += A[i - 1]; } if (sum1 == sum0) return i; } return -1; }