🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Kadane's Algorithm: all 13 questions

Quiz: Kadane's Algorithm · Question 2 of 13

In Kadane's algorithm, when does the current subarray "restart" at x?

In Kadane's algorithm, when does the current subarray "restart" at x?

  1. A.When x is negative
  2. B.When the running sum before x is negative, so x alone is bigger than cur + x
  3. C.Every time best improves
  4. D.Never — it always extends
Answer & explanation

Correct answer: When the running sum before x is negative, so x alone is bigger than cur + x

cur + x < x exactly when cur < 0: a negative running sum can only make things worse.

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 →