[코테] 53. Maximum Subarray
Solution, failed to solve
1
2
3
4
5
6
7
8
9
10
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
cur_sum = nums[0]
tot_sum = nums[0]
for num in nums[1:]:
cur_sum = max(num, cur_sum + num)
tot_sum = max(tot_sum, cur_sum)
return tot_sum
This post is licensed under CC BY 4.0 by the author.