🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Sliding Window Quiz: all 8 questions

Sliding Window Quiz · Question 5 of 8

In the variable-window template for a LONGEST valid window, when do you update the answer?

In the variable-window template for a LONGEST valid window, when do you update the answer?

  1. A.Before expanding the window
  2. B.Inside the shrinking loop
  3. C.After shrinking, once the window is valid again
  4. D.Only at the very end
Answer & explanation

Correct answer: After shrinking, once the window is valid again

Expand right, shrink while invalid, then the window is valid — that's when it's a candidate for the longest.

Can you get the rest right without peeking?

Take the timed Sliding Window Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →