Untitled
unknown
plain_text
a year ago
304 B
14
Indexable
class Solution {
public:
int maxSubArray(vector<int>& nums) {
int ans = INT_MIN, temp = 0;
for (int i = 0; i < nums.size(); i++) {
temp += nums[i];
temp = max(temp, nums[i]);
ans = max(ans, temp);
}
return ans;
}
};Editor is loading...
Leave a Comment