Skip to content

Commit 4602e17

Browse files
committed
Added day3
1 parent cde643c commit 4602e17

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

leetcode/day3.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int maxSubArray(vector<int>& nums) {
4+
5+
int ans = INT_MIN, t = 0;
6+
7+
for(int x : nums){
8+
t+= x;
9+
ans = max(ans,t);
10+
11+
t= max(t,0);
12+
}
13+
14+
return ans;
15+
16+
}
17+
};

0 commit comments

Comments
 (0)