Sliding Window

Keep a window over part of an array or string, and move its edges instead of starting over each time. It turns many 'every substring' problems from quadratic to linear. Look for a contiguous range with a limit, like Longest Substring Without Repeating Characters.

27 problems · 11 with a video · 4 to practice in an AI round

Sliding Window problems
#ProblemDifficultyVideoAI round
1Longest Substring Without Repeating CharactersMediumAI round
2Sliding Window MaximumHardAI round
3Minimum Window SubstringHardAI round
4Minimum Size Subarray SumMediumAI round
5Longest Repeating Character ReplacementMedium
6Find All Anagrams in a StringMedium
7Permutation in StringMedium—
8Max Consecutive Ones IIIMedium
9Find K Closest ElementsMedium—
10Contains Duplicate IIEasy—
11Subarray Product Less Than KMedium—
12Maximum Points You Can Obtain from CardsMedium—
13Subarrays with K Different IntegersHard—
14Longest Substring with At Least K Repeating CharactersMedium—
15Fruit Into BasketsMedium
16Frequency of the Most Frequent ElementMedium—
17Count Number of Nice SubarraysMedium—
18Shortest Subarray with Sum at Least KHard—
19Binary Subarrays With SumMedium—
20Maximum Average Subarray IEasy
21Longest Continuous Subarray With Absolute Diff Less Than or Equal to LimitMedium—
22Smallest Range Covering Elements from K ListsHard—
23Maximum Number of Vowels in a Substring of Given LengthMedium
24Maximize the Confusion of an ExamMedium
25Longest Substring with At Most K Distinct CharactersMedium—
26Longest Substring with At Most Two Distinct CharactersMedium—
27Max Consecutive Ones IIMedium—

Practice in an AI round

Four of these are AI rounds: 30 minutes, an AI agent beside your code, then a scored report.

Practice Longest Substring Without Repeating Characters in an AI round