Greedy Algorithms8 sections · 316 units
Open in Course

Quiz: Kadane's Algorithm

Understanding the reset

Quiz question placeholder with incorrect complexity. This will be filled with a proper quiz question. Time: O(n)O(n). Space: O(1)O(1). The placeholder ensures the unit structure remains intact while the quiz content is developed separately from the main flow.

Check Your Understanding

In Kadane's algorithm, why do we reset currentSum to 0 when it becomes negative?

  1. A.To handle edge cases with all negative numbers
  2. B.To save memory
  3. C.Because a negative prefix would only decrease any future subarray sum
  4. D.To ensure the algorithm runs in linear time
Start the roadmap to answer the quizzes and solve the challenges