Skip to content

Commit

Permalink
Time: 1031 ms (37.50%), Space: 28 MB (40.39%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
shsewonitw committed May 9, 2022
1 parent 175510c commit 833d876
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 53-maximum-subarray/53-maximum-subarray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
# Kadane's algorithm
for i in range(1, len(nums)):
if nums[i - 1] > 0:
nums[i] += nums[i - 1]
return max(nums)

0 comments on commit 833d876

Please sign in to comment.