How can the following simple implementation of sum be faster?
sum
private long sum( int [] a, int begin, int end ) { if( a == null ) { ret
Here is my solution and I scored 100%
public static int solution(int[] A) { double sum = A.Sum(d => (double)d); double leftSum=0; for (int i = 0; i < A.Length; i++){ if (leftSum == (sum-leftSum-A[i])) { return i; } else { leftSum = leftSum + A[i]; } } return -1; }