Sliding Window
Uses a moving window to work with contiguous parts of an array or string.
5
2
8
2
4
7
L
R
Initialize window
Where It's Used
- Finding the longest or shortest substring/subarray that meets a condition.
- Problems involving contiguous segments of an array or string.
- Calculating the maximum or minimum value within a moving window.
Problems Using This Pattern
Longest Substring Without Repeating Characters
Sliding Window
Minimum Size Subarray Sum
Sliding Window