TapeEquilibrium
1 /// <summary> 2 /// Solution 3 /// 100/100 4 /// </summary> 5 /// <param name="A"></param> 6 /// <returns></returns> 7 public static int solution(int[] A) 8 { 9 int sumL = A[0]; 10 int sumR = 0; 11 int min = 0; 12 for (int i = 1; i < A.Length; i++) 13 sumR += A[i]; 14 min = Math.Abs(sumL - sumR); 15 for (int i = 1; i < A.Length - 1; i++) 16 { 17 sumL += A[i]; 18 sumR -= A[i]; 19 if (Math.Abs(sumL - sumR) < min) 20 min = Math.Abs(sumL - sumR); 21 } 22 return min; 23 }