标签:problem tps code leetcode bar 最大 for 连续子数组 +=
链接: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; } };
标签:problem tps code leetcode bar 最大 for 连续子数组 +=
原文地址:https://www.cnblogs.com/clown9804/p/12409062.html