1 public class Solution { 2 public int FindGreatestSumOfSubArray(int[] array) { 3 int sum=array[0]; 4 int flag=0; 5 int res = array[0]; 6 if(array.length==0) return 0; 7 for(int i=1;i<array.length;i++) 8 { 9 sum = Math.max(sum+array[i],array[i]); 10 res = Math.max(res,sum); 11 } 12 return res; 13 } 14 }
剑指offer——连续子数组的和
猜你喜欢
转载自www.cnblogs.com/wangyufeiaichiyu/p/11084074.html
今日推荐
周排行