public class Solution { public int FindGreatestSumOfSubArray(int[] array) { int sum=0; int res=array[0]; for (int i=0;i<array.length;i++){ sum = sum + array[i]; if(sum>res){ res=sum; } if(sum<0){ sum=0; } } return res; } }
原文地址:https://www.cnblogs.com/q-1993/p/10871889.html
时间: 2024-11-05 23:37:10