Given a binary array and an integer k, find the longest run of 1s you can create by flipping at most k zeros. Master the variable sliding window pattern that solves this in O(n) time and O(1) space — and learn the follow-up questions Google and Meta actually ask after you get it right.
Master LeetCode 3 — the canonical sliding window problem. Understand the "shrink from left" insight, the critical stale-index bug with max(), and both set-based and hashmap-optimized solutions in Python and JavaScript. Includes a full step-by-step dry run and follow-up problems LC 340 and LC 159.
Master LeetCode 209 from first principles: understand why a variable-size shrinkable sliding window is the insight that cracks this problem in O(n), trace through every pointer movement on a real example, learn the three common interview mistakes, and be ready for the O(n log n) binary search follow-up that Amazon and Microsoft love to ask.
Master LeetCode 76 — the gold-standard Hard sliding window problem asked at Google, Meta, and Amazon. Learn the "formed" counter trick that reduces window validity checks from O(|t|) to O(1), trace through a full dry run, and avoid the five bugs that most often break this one.
Master LeetCode 689 with a full visual dry run, left/right DP insight, Python and JavaScript solutions, and real interview follow-ups on generalizing to k windows.
Master LeetCode 1493 with an intuition-first sliding window approach. Learn why you subtract 1 from the window size, trace through a real dry run, and ace every follow-up question an interviewer throws at you.
LC 992 is one of the cleanest examples of a non-obvious reduction in competitive programming. Learn the "exactly K = atMost(K) minus atMost(K-1)" insight, trace through a full visual dry run, and understand how this single pattern unlocks five related hard problems in one shot.
LeetCode 239 Sliding Window Maximum is a Google classic that returns the max of every length-k window. The optimal answer maintains a monotonic decreasing deque of indices for amortised O(n) time.
LeetCode 76 Minimum Window Substring is a Google staple solved with a two-pointer sliding window plus a need-and-have frequency counter. Optimal solution runs in O(n + m) time and O(m) space.
Compute the median for each sliding window using two heaps with lazy deletion — the definitive template for dynamic order statistics in interview problems.
Count ping requests within the last 3000ms using a FIFO queue that evicts expired timestamps from the front in O(1) amortized time. A clean introduction to the sliding window queue pattern used in rate limiters and real-time counters.
Find the maximum in every sliding window of size k using a monotonic decreasing deque that maintains candidate indices in O(n) total time. The hardest and most elegant deque problem — mastering this unlocks Shortest Subarray with Sum At Least K and Jump Game VI.
Solve LeetCode 1696 Jump Game VI with a monotonic deque to track the sliding window maximum of DP states in O(n). A high-signal FAANG interview problem.
Solve LeetCode 362 Design Hit Counter using a queue or fixed-size circular buffer for O(1) amortized hits and constant-time getHits. A FAANG system design favorite.
A curated and battle-tested set of the string problems that show up most often in Meta and Google onsite loops, with the canonical pattern for each. Cover this list and you cover roughly 80 percent of string-heavy FAANG screens.
Master the two pointer and sliding window patterns that drive 15-20 percent of FAANG array and string interviews at Meta, Google, Amazon, Apple, and Netflix. This guide indexes 60 problems and the techniques behind every variant.
LeetCode 1004 Max Consecutive Ones III is a Google and Amazon variable sliding window problem. Track the count of zeros inside the window and shrink from the left whenever it exceeds k to find the longest contiguous run of ones after k flips.
LeetCode 1176 Diet Plan Performance is a Google fixed sliding window problem. Maintain a running sum of exactly k consecutive calories to score points or penalties in O(n) time and O(1) space.
LeetCode 3 Longest Substring Without Repeating Characters is one of the top five most asked questions at Meta and Amazon. Master the variable sliding window with a hash map to solve it in O(n) time and O(min n,m) space.
LeetCode 424 — a classic FAANG sliding window problem (Google, Microsoft, Amazon). Master the max-frequency invariant that powers the optimal O(n) solution.
LeetCode 567 — detect if any permutation of s1 appears as a substring of s2 using a fixed-size sliding window. Frequently asked at Google, Amazon, and Microsoft.
LeetCode 904 — find the longest contiguous subarray with at most two distinct values. A reskinned classic that appears in Google, Amazon, and Microsoft interviews.
LeetCode 1695 — find the maximum sum of a subarray with all unique values using a HashSet sliding window. A favorite at Google and Amazon for testing window invariants.
LeetCode 713 Subarray Product Less Than K is asked at Google, Amazon, and Stripe. Count contiguous subarrays in O(n) using a multiplicative sliding window.
LeetCode 1423 Maximum Points You Can Obtain from Cards is asked at Google, Amazon, and Meta. Convert pick-from-ends into a fixed-size minimum-window problem in O(n).
LeetCode 1248 Count Number of Nice Subarrays is asked at Google and Amazon. Convert "exactly k odds" into atMost(k) minus atMost(k-1) for an O(n) solution.
LeetCode 930 Binary Subarrays With Sum is asked at Google, Amazon, and Meta. Count subarrays with exact sum in O(n) using atMost(goal) minus atMost(goal-1).
LeetCode 1838 Frequency of the Most Frequent Element is asked at Google and Amazon. Sort, then slide a window where total cost to lift everything to the rightmost value is at most k.
LeetCode 1658 Minimum Operations to Reduce X to Zero is asked at Amazon, Google, and Meta. Reframe to longest subarray summing to total minus x for an O(n) solution.
LeetCode 992 Subarrays with K Different Integers is a Google, Amazon, and Meta hard. Solve in O(n) using the atMost(K) minus atMost(K-1) decomposition.
LeetCode 1234 Replace the Substring for Balanced String is asked at Google and Amazon. Find the minimum window to replace in O(n) using a shrinkable sliding window over QWER frequencies.
LC 1888 asks for the minimum flips to make a binary string alternating after any rotations. Double the string and slide a fixed window of size n against both target patterns — the canonical circular sliding window trick.
LC 1456 asks for the maximum vowels in any substring of length k. A canonical fixed-size sliding window — add the new right character, subtract the departing left character, track the running max. O(n) time, O(1) space.
LC 1151 asks for minimum swaps to group all 1s in a circular binary array. Count total 1s to set the window size, then maximize 1s inside any window position using modulo indexing. O(n) time, O(1) space.
LC 2516 asks for the minimum minutes to collect at least k of each character from a string's ends. Flip it: find the longest middle window you can skip so the outside has enough of each character. O(n) time, O(1) space.
LC 1052 maximizes satisfied customers by finding the optimal k-minute grumpiness suppression window. Decompose into a fixed base plus a variable bonus — then find the max-bonus window with a standard fixed-size sliding window. O(n) time, O(1) space.
LC 1984 asks for the minimum max-minus-min over any k chosen scores. The optimal k scores are always contiguous in sorted order — sort once then scan windows of size k in O(n log n) time, O(1) space.
LC 1208 asks for the longest substring of s transformable to t within total cost maxCost, where each character costs the absolute ASCII difference. Classic variable sliding window: expand right, shrink left while cost exceeds budget. O(n) time, O(1) space.
LC 1358 counts substrings containing at least one a, b, and c. Track the last-seen index of each character — the count of valid substrings ending at position i is min(last_seen) + 1. O(n) time, O(1) space.
LC 2260 asks for the shortest consecutive sequence of cards containing a matching pair. Track the last-seen index of each card value — update the minimum window each time a duplicate is encountered. O(n) time, O(n) space.
Count subarrays where score = sum × length is less than k using a shrinkable sliding window with a running sum. Counting all valid subarrays ending at each right pointer is the key trick that avoids an inner loop.
Find the smallest window in s containing all characters of t using have/need counters and a frequency map. The canonical hard sliding-window problem asked at every top tech company.
Find the maximum in every sliding window of size k in O(n) using a monotonic decreasing deque of indices — the classic hard problem that separates senior engineers from the rest.
Find the shortest subarray whose sum is at least k, even with negative numbers, using a monotone increasing deque on prefix sums — the canonical hard problem where a simple sliding window fails.
Find the longest substring containing at most 2 distinct characters using a variable sliding window backed by a character frequency map — a premium LinkedIn and Google problem with a clean generalization to k distinct.
Find the longest contiguous subarray of 1s after deleting exactly one element. Reframe as "longest window with at most one zero," then subtract 1 for the mandatory deletion. A clean shrinkable window problem.
Complete master cheatsheet of every two-pointer and sliding window pattern used in coding interviews. Includes template code, problem index, decision tree, and MAANG priority list.