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         }

 

posted @ 2015-07-25 20:40  叫我霍啊啊啊  阅读(192)  评论(0编辑  收藏  举报