参考资料来源:
作者:jyd
链接:https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/solution/mian-shi-ti-42-lian-xu-zi-shu-zu-de-zui-da-he-do-2/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
1 #define max(a,b) a>b?a:b 2 int maxSubArray(int* nums, int numsSize){ 3 int res=nums[0]; 4 for(int i=1;i<numsSize;i++) 5 { 6 nums[i]+=max(nums[i-1],0); 7 res=max(res,nums[i]); 8 } 9 return res; 10 }