Medium · Dynamic programming
Maximum Subarray
You are given a list of integers, nums. Find the run of numbers sitting next to each other that has the largest sum, and return that sum.
- The run must hold at least one number.
- The numbers can be negative. If all of them are, the answer is the largest single one.
- Return the sum, not the run.
nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4] → 6 ([4, -1, 2, 1])Record your take