Skills101
← All practice quizzes

Sliding Window Quiz

8 questions10 minPass: 60%+10 XP on first pass

Fixed and variable windows, when to shrink, and when the technique does not apply.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1Select all that apply

    Which questions are typical sliding-window problems? (select all that apply)

  2. Question 2

    A fixed window of size k slides one step right. How is the new sum computed in O(1)?

  3. Question 3

    What is the maximum sum of 3 consecutive elements in [2, 1, 5, 1, 3, 2]?

  4. Question 4

    What is the length of the longest substring without repeating characters in "abcabcbb"?

  5. Question 5

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

  6. Question 6

    What is the time complexity of the variable sliding window, even with the inner while loop?

  7. Question 7

    Why does a sum-based sliding window fail when the array contains negative numbers?

  8. Question 8

    What is the length of the shortest subarray of [2, 3, 1, 2, 4, 3] with sum ≥ 7?