Today, I solved "Maximum Subarray."
Description:
Solution:
As we can see, we don't have to include the first negative array.
curSum is a cumulative sum of numbers.
If curSum is negative, it means that subarray is not for maximum sum.
I use max() to compare the curSum and maxSub.
'LeetCode ๐๏ธ > Array' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
153. Find Minimum in Rotated Sorted Array (0) | 2023.05.29 |
---|---|
152. Maximum Product Subarray (0) | 2023.05.28 |
238. Product of Array Except Self (0) | 2023.01.29 |
217. Contains Duplicate (0) | 2023.01.28 |
121. Best Time to Buy and Sell Stock (0) | 2023.01.28 |