Sliding Window Quiz
Editorial
11 questions across the three Sliding Window lessons: which window a task needs, what one step of each template does, what a step counts, and what a small bug returns. Pick an answer to see whether it's right and why. Nothing is saved, so you can take it again.
If one trips you up, its lesson is Introduction to Sliding Window, Variable-Size Sliding Window: Longest and Shortest or Counting Subarrays with a Sliding Window.
Quiz
1 / 11Multiple choice
Find the largest sum of any 5 consecutive numbers. Which approach fits?
Multiple choice
Find the longest substring with at most 3 different letters. Which approach fits?
Multiple choice
Count the subarrays with exactly 3 odd numbers. Which approach fits?
Multiple choice
Count the subarrays whose sum is exactly k, when the numbers can be negative. Which approach fits?
Multiple choice
Find All Anagrams with p = "abc". Before any letter enters, how many of the 26 letters already agree (
matches)?Multiple choice
Longest Substring Without Repeating Characters on "pwwkew": the window is "pw" and the next letter is w. What's the window after this step?
Multiple choice
Minimum Size Subarray Sum with target 7: the window [2, 3, 1, 2] sums to 8. What does the template do next?
Multiple choice
A counting solution's window follows an at-most rule with
left = 2 and right = 5. How many subarrays does this step add?Multiple choice
On some array, at most 3 different values counts 45 subarrays and at most 2 counts 21. How many have exactly 3?
Multiple choice
A Longest Substring Without Repeating Characters solution records the best length before it shrinks. What does it return for "aa"?
Multiple choice
For which problem can the shrinking
while become an if?