Maximum Subarray
Try to solve the Maximum Subarray problem.
We'll cover the following
1 of 2
2 of 2
Understand the problem#
Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps you check if you’re solving the correct problem:
Maximum Subarray
1
What is the correct output if the following array is passed as input?
nums = [-2, 1, 0, 4, -1, 7, 1, 5, -8]
A)
15
B)
17
C)
16
Question 1 of 20 attempted
Try it yourself#
Implement your solution in the following coding playground:
The optimal solution to this problem runs in O(n) time and takes O(1) space.
Python
usercode > main.py
Maximum Subarray
You might want to go over the Dynamic Programming pattern again.
Solution: Maximum Profit in Job Scheduling
Solution: Maximum Subarray