← All problems
Maximum Subarray
Find the contiguous subarray with the largest sum and return that sum.
Complexity
Time O(n), Space O(1)
Common pitfalls
- Resetting cur to 0 breaks all-negative arrays
- Confusing 'ending here' with 'anywhere'
Your solution
Log in to save your code and track progress.