53. Maximum Subarray
https://leetcode.com/problems/maximum-subarray/
Problem
Given an integer array nums
, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Follow up: If you have figured out the O(n)
solution, try coding another solution using the divide and conquer approach, which is more subtle.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= nums.length <= 2 * 104
-231 <= nums[i] <= 231 - 1
Solution
1. DP
2. Recursive
#recursion
#dp
#math
#important
Last updated
Was this helpful?