Intermediate Sliding Window Problems for Coding Interviews
81 intermediate Sliding Window problems from real coding interviews, each with test cases you can run online. By difficulty they split into 0 basic, 81 intermediate and 0 advanced. The companies that ask them most often are Amazon, Google, Meta, Microsoft.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Maximum Subarray (Intermediate)
- Minimum Size Subarray Sum (Intermediate)
- Subarray Sum Equals K (Intermediate)
- Maximum Vowels in a Window (Intermediate)
- Sum of Odd-Length Subarrays (Intermediate)
- Count Subarrays With K Odd Numbers (Intermediate)
- Subarrays Divisible by K (Intermediate)
- Shortest Unsorted Middle Part (Intermediate)
- Subarrays With Product Less Than K (Intermediate)
- Longest Mountain Subarray (Intermediate)
- Binary Subarrays With Target Sum (Intermediate)
- Arithmetic Slices (Intermediate)
- Longest XOR Subarray (Intermediate)
- Count Palindromic Substrings (Intermediate)
- Maximum Sum of Distinct Window (Intermediate)
- Count Subarrays With Fixed Bounds (Intermediate)
- Maximum Product Subarray (Intermediate)
- Subarray Sum Equals K (Intermediate)
- Maximum Circular Subarray (Intermediate)
- Shortest Unsorted Subarray Length (Intermediate)
- Maximum Length Subarray With Sum Zero (Intermediate)
- Longest Bounded-Difference Segment (Intermediate)
- Median of Sliding Windows (Intermediate)
- Minimum Operations to Sort by Reversals (Intermediate)
- Maximum Subarray With Updates (Intermediate)
- Count Substrings With Exactly K Distinct (Intermediate)
- Minimum Window With All Vowels (Intermediate)
- Count Subarrays With Sum Multiple of K (Intermediate)
- Minimum Length Subarray With Sum At Least K (Intermediate)
- Longest Subarray With Bounded Maximum (Intermediate)
- Maximum of Minimum for Every Window Size (Intermediate)
- Longest Turbulent Segment (Intermediate)
- Session Window Merge (Intermediate)
- Rolling Median With Late Events (Intermediate)
- Rolling Correlation (Intermediate)
- Ways to Split Array Into Good Subarrays (Intermediate)
- Sum of Subarray Ranges (Intermediate)
- Subarrays Where Max Appears at Least K Times (Intermediate)
- Sublist Search (Intermediate)
- Maximum Erasure Value (Intermediate)
- Longest Nice Subarray (Intermediate)
- Count Complete Subarrays (Intermediate)
- Shortest Subarray With OR at Least K (Intermediate)
- Longest Equal Subarray After Deletions (Intermediate)
- Sliding Subarray Beauty (Intermediate)
- K Radius Subarray Averages (Intermediate)
- Power of K-Size Subarrays (Intermediate)
- XOR Queries of a Subarray (Intermediate)
- Subarrays With Odd Sum (Intermediate)
- Two Non-Overlapping Subarrays With Target Sum (Intermediate)
- Number of Smooth Descent Periods (Intermediate)
- Bitwise ORs of Subarrays (Intermediate)
- Count Subarrays With GCD Equal to K (Intermediate)
- Count Subarrays With LCM Equal to K (Intermediate)
- Smallest Window Containing Every Distinct Character (Intermediate)
- Count Subarrays Where Maximum Appears at Both Ends (Intermediate)
- Maximum Sum of Two Non-Overlapping Subarrays (Intermediate)
- Longest Zigzag Subarray (Intermediate)
- Longest Subarray With Absolute Difference Limit (Intermediate)
- Count Subarrays With All Distinct Elements (Intermediate)
- Minimum Increments on Subarrays to Form Target (Intermediate)
- Maximum Subarray Sum With One Deletion (Intermediate)
- Count Subarrays With Score Less Than K (Intermediate)
- Maximum Score Jumping With Window (Intermediate)
- Subarrays With Sum Divisible by Length (Intermediate)
- Count Subarrays With Equal Odd and Even Counts (Intermediate)
- Longest Subarray With Sum Divisible by K (Intermediate)
- Number of Subarrays With Sum Between L and R (Intermediate)
- Longest Subarray With Nonzero AND (Intermediate)
- Sum of All Submatrices (Intermediate)
- Longest Subarray of Consecutive Values (Intermediate)
- Count Subarrays That Are Permutations (Intermediate)
- Balanced Rise and Fall Subarray (Intermediate)
- Subarrays With Zero XOR (Intermediate)
- XOR of All Subarray XORs (Intermediate)
- Sliding Window Rate Limit Accepted Requests (Intermediate)
- Window Sum Spread (Intermediate)
- Longest Window Under Budget (Intermediate)
- Covered Time Inside a Window (Intermediate)
- Closest Window Hamming Distance (Intermediate)
Related
Frequently asked questions
How do I get good at sliding window problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run sliding window problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.