DEV Community

Shashank Trivedi
Shashank Trivedi

Posted on

Sliding Window Questions

Easy Level:

  1. Maximum Average Subarray I
    Problem: Given an array, find the contiguous subarray of given length k that has the maximum average.

  2. Longest Substring Without Repeating Characters
    Problem: Find the length of the longest substring without repeating characters.

  3. 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.

  4. 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:

  1. Longest Substring with At Most Two Distinct Characters
    Problem: Find the length of the longest substring that contains at most two distinct characters.

  2. 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.

  3. 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.

  4. Subarrays with K Different Integers
    Problem: Find the number of subarrays with exactly k distinct integers.

  5. Grumpy Bookstore Owner
    Problem: Maximize the number of satisfied customers by applying a "non-grumpy" behavior on a contiguous window of customers.

  6. Sliding Window Maximum
    Problem: Given an array, find the maximum value in every sliding window of size k.

Hard Level:

  1. Minimum Window Substring
    Problem: Given two strings, find the minimum window in the first string that contains all characters of the second string.

  2. Longest Substring with At Most K Distinct Characters
    Problem: Find the length of the longest substring that contains at most k distinct characters.

  3. Shortest Subarray with Sum at Least K
    Problem: Find the shortest subarray with a sum of at least k.

  4. Subarray Product Less Than K
    Problem: Find the number of contiguous subarrays where the product of all elements is less than k.

  5. Count Number of Nice Subarrays
    Problem: Find the number of subarrays that contain exactly k odd numbers.

Top comments (0)