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 f011d0f commit 80d9991Copy full SHA for 80d9991
1 file changed
maximum-subarray/gcount85.py
@@ -0,0 +1,19 @@
1
+"""
2
+# Intuition
3
+max(전 위치까지의 sum + 지금 위치 값, 지금 위치의 값)
4
+
5
+# Complexity
6
+- Time complexity: nums의 길이를 N이라고 할 때 O(N)
7
8
+- Space complexity: O(1)
9
10
11
12
+class Solution:
13
+ def maxSubArray(self, nums: List[int]) -> int:
14
+ a = nums[0]
15
+ best = a
16
+ for i in range(1, len(nums)):
17
+ a = max(a + nums[i], nums[i])
18
+ best = max(a, best)
19
+ return best
0 commit comments