Skip to content

Commit 07512f6

Browse files
authored
feat: added leetcode 53 java solution (Tahanima#108)
1 parent 89af38d commit 07512f6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int maxSubArray(int[] nums) {
3+
int maxSum = Integer.MIN_VALUE;
4+
int sum = 0;
5+
6+
for (int num : nums) {
7+
sum += num;
8+
maxSum = Math.max(sum, maxSum);
9+
10+
if (sum < 0) {
11+
sum = 0;
12+
}
13+
}
14+
15+
return maxSum;
16+
}
17+
}

0 commit comments

Comments
 (0)