I have curated a list of leetode questions based on sliding window approach.
Any question where something is asked related to subarray, substring, consecutive element, asking max , min , longest shortest might be solved using sliding window technique
Easy Level:
Maximum Average Subarray I
Problem: Given an array, find the contiguous subarray of given length k that has the maximum average.Longest Substring Without Repeating Characters
Problem: Find the length of the longest substring without repeating characters.Minimum Size Subarray Sum
Problem: Find the minimal length of a contiguous subarray of which the sum is greater than or equal to a given target.Find All Anagrams in a String
Problem: Given two strings, find all start indices of the first string's anagrams in the second string.
Medium Level:
Longest Substring with At Most Two Distinct Characters
Problem: Find the length of the longest substring that contains at most two distinct characters.Permutation in String
Problem: Given two strings, check if one string is a permutation of the other within a sliding window of the second string.Longest Repeating Character Replacement
Problem: Find the length of the longest substring that can be turned into the same character by replacing at most k characters.Subarrays with K Different Integers
Problem: Find the number of subarrays with exactly k distinct integers.Grumpy Bookstore Owner
Problem: Maximize the number of satisfied customers by applying a "non-grumpy" behavior on a contiguous window of customers.Sliding Window Maximum
Problem: Given an array, find the maximum value in every sliding window of size k.
Hard Level:
Minimum Window Substring
Problem: Given two strings, find the minimum window in the first string that contains all characters of the second string.Longest Substring with At Most K Distinct Characters
Problem: Find the length of the longest substring that contains at most k distinct characters.Shortest Subarray with Sum at Least K
Problem: Find the shortest subarray with a sum of at least k.Subarray Product Less Than K
Problem: Find the number of contiguous subarrays where the product of all elements is less than k.Count Number of Nice Subarrays
Problem: Find the number of subarrays that contain exactly k odd numbers.
Top comments (0)