Skip to content

Commit 2083c15

Browse files
committed
maximum-subarray solution
1 parent c5c8548 commit 2083c15

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

maximum-subarray/yayyz.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution:
2+
def maxSubArray(self, nums: List[int]) -> int:
3+
curr_sum = max_sum = nums[0]
4+
for num in nums[1:]:
5+
curr_sum = max(num, curr_sum + num)
6+
max_sum = max(max_sum, curr_sum)
7+
return max_sum

0 commit comments

Comments
 (0)