← Quiz: Kadane's Algorithm: all 13 questions
Quiz: Kadane's Algorithm · Question 3 of 13
What is the maximum subarray sum of [-5, -2, -7] (subarrays must be non-empty)?
What is the maximum subarray sum of [-5, -2, -7] (subarrays must be non-empty)?
- A.0
- B.-2
- C.-14
- D.-5
Answer & explanation
Correct answer: -2
With every number negative, the best non-empty subarray is the single largest element.
Can you get the rest right without peeking?
Take the timed Quiz: Kadane's Algorithm quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →