← All topics
Quiz: Kadane's Algorithm: questions with answers
13 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. What does this print? (code)
- Q2. In Kadane's algorithm, when does the current subarray "restart" at x?
- Q3. What is the maximum subarray sum of [-5, -2, -7] (subarrays must be non-empty)?
- Q4. What are the time and extra space of Kadane's algorithm?
- Q5. For the maximum CIRCULAR subarray, a wrapping subarray's best sum equals:
- Q6. Why does the maximum PRODUCT subarray track the smallest product as well?
- Q7. What does this print? (code)
- Q8. Kadane's algorithm is an example of which technique?
- Q9. What does this print? (code)
- Q10. Why does Kadane start with best = a[0] instead of best = 0?
- Q11. What does this print? (code)
- Q12. In the maximum circular subarray code, why return bestmax when it is negative?
- Q13. In the maximum product subarray, why swap hi and lo when x is negative?