First Update

This commit is contained in:
huihut
2018-02-09 21:47:58 +08:00
commit 6b742a5393
11 changed files with 298 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
#define MIN_INT -2147483648
class Solution {
public:
int maxSubArray(vector<int>& nums) {
int max = MIN_INT, temp = 0;
for(auto i = 0; i < nums.size(); ++i) {
temp += nums[i];
if(temp > max) max = temp;
if(temp < 0) temp = 0;
}
return max;
}
};