链接:https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/submissions/
代码:
class Solution { public: int maxSubArray(vector<int>& nums) { int res = INT_MIN, s = 0; for (auto x: nums) { if (s < 0) s = 0; s += x; res = max(res, s); } return res; } };
原文地址:https://www.cnblogs.com/clown9804/p/12409062.html
时间: 2024-10-29 00:49:37