We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fcd56b5 commit 809287fCopy full SHA for 809287f
src/leetcode/editor/en/[0053] Maximum Subarray.java
@@ -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