Sliding Window
The sliding window is a powerful technique for array and string problems, particularly when searching for optimal subarrays or substrings.
Key Concepts
- Fixed Window: The size of the window remains constant as it slides through the array (e.g., finding the maximum sum of
kconsecutive elements). - Variable Window: The window expands or contracts dynamically based on certain conditions (e.g., maintaining unique characters or a specific sum limit).
Pattern Recognition
Look for the sliding window pattern when the problem asks for:
- Maximum/minimum subarray or substring.
- Longest or shortest sequence satisfying some constraint.
- Checking for a permutation or anagram within a string.
Problem List
Explore the curated list of sliding window problems in this section. See individual problem pages for in-depth diagrams, concepts, and optimal implementations.
Last updated on
Spotted something unclear or wrong on this page?