Leetcode 剑指 Offer 42. 连续子数组的最大和(DAY 25)---- 动态规划
作者:互联网
原题题目
代码实现(首刷自解)
int maxSubArray(int* nums, int numsSize){
int sum = -101,tempsum = 0,i;
for(i=0;i<numsSize;i++)
{
tempsum += nums[i];
if(tempsum > sum)
sum = tempsum;
if(tempsum < 0)
tempsum = 0;
}
return sum;
}
标签:numsSize,25,原题,Offer,int,sum,nums,42,tempsum 来源: https://blog.csdn.net/qq_37500516/article/details/112795872