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 2dca348 commit a6b54a4Copy full SHA for a6b54a4
maximum-subarray/eunhwa99.java
@@ -0,0 +1,15 @@
1
+// 시간 복잡도: DP -> O(N)
2
+// 공간 복잡도: nums 배열 크기 - O(N)
3
+
4
+class Solution {
5
+ public int maxSubArray(int[] nums) {
6
+ int currentSum = nums[0];
7
+ int maxSum = currentSum;
8
+ for (int i = 1; i < nums.length; ++i) {
9
+ currentSum = Math.max(currentSum + nums[i], nums[i]);
10
+ maxSum = Math.max(maxSum, currentSum);
11
+ }
12
13
+ return maxSum;
14
15
+}
0 commit comments