Follow Kadane's two numbers
Warm-up · Trace the algorithm · about 5 min
Follow Kadane's algorithm on 1, −3, 2, 1, −1. Answer each question before the step plays.
Example 1
Input:
{"values":[1,-3,2,1,-1]}
Output:
3
Constraints
- The trace uses the values shown.
Learn the idea first: Kadane's algorithm and maximum subarray, a visual lesson.
More Kadane's algorithm and maximum subarray problems
- Best time to buy and sell once Standard
- Maximum circular subarray Standard
- Maximum product subarray Challenge