public int maxSubsequenceSum(int[] arr){
int nowSum = 0;
int max = 0;
for(int num : arr){
nowSum += num;
if(nowSum > max ){
max = nowSum;
}
if(nowSum < 0){
nowSum = 0;
}
}
return max;
}
最大子序列最佳解法
最新推荐文章于 2021-02-28 04:12:24 发布