MaxSliceSum【★★★★★】

 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 maxEndingHere = A[0];
10             int maxSofar = A[0];
11             for (int i = 1; i < A.Length; i++)
12             {
13                 maxEndingHere = Math.Max(A[i], maxEndingHere + A[i]);
14                 maxSofar = Math.Max(maxEndingHere, maxSofar);
15             }
16             return maxSofar;
17         }
原文地址:https://www.cnblogs.com/HuoAA/p/4676540.html