Blind 75 Sliding Window Questions
4 problems · Free practice
A sliding window tracks a contiguous part of an input while its boundaries move forward. The key is a precise validity condition: which counts or values tell you the current window satisfies the problem? Longest-window and shortest-window questions use different moments to update the answer, so make that choice explicit.
Practice sliding window
Best Time to Buy and Sell Stock
EasyGiven daily prices, choose one buy day and a later sell day to maximize profit. You may make no transaction, giving profit zero.
Longest Substring Without Repeating Characters
MediumReturn the length of the longest contiguous substring whose characters are all distinct.
Longest Repeating Character Replacement
MediumFor a string of uppercase English letters and a budget k, find the longest substring that can become one repeated letter after changing at most k positions.
Minimum Window Substring
HardFind the shortest substring of s containing every character of t, including repeated copies. Return an empty string if no such window exists; if t is empty, also return an empty string.
What to focus on
- Define what makes the window valid before writing the loop.
- Update counts when an element enters and when it leaves.
- Explain whether you record the answer before shrinking, after shrinking, or during shrinking.