Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 809287f

Browse files
Solved 53
1 parent fcd56b5 commit 809287f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package leetcode.editor.en;
2+
3+
import java.util.*;
4+
5+
class MaximumSubarray {
6+
7+
//leetcode submit region begin(Prohibit modification and deletion)
8+
class Solution {
9+
public int maxSubArray(int[] nums) {
10+
int tempSum = 0, out = Integer.MIN_VALUE;
11+
for (int i = 0; i < nums.length; i++) {
12+
tempSum += nums[i];
13+
if (out < tempSum) out = tempSum;
14+
if (tempSum < 0) tempSum = 0;
15+
}
16+
return out;
17+
}
18+
}
19+
//leetcode submit region end(Prohibit modification and deletion)
20+
21+
22+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /