首页 > 其他 > 详细

MaxSliceSum【看答案了】【★★★★★】

时间:2015-07-25 21:23:03      阅读:190      评论:0      收藏:0      [点我收藏+]
 1         /// <summary>
 2         /// Solution
 3         /// 通过率 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         }

 

MaxSliceSum【看答案了】【★★★★★】

原文:http://www.cnblogs.com/HuoAA/p/4676540.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!