Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Sliding Window Pattern Lab
Patterns
Concept shape
Practice pattern
0
1
2
3
4
5
Definition
Maintain a window over a sequence and update state as the window moves.
Step 1 / 5
Concept shape
Patterns Practice pattern
Sliding Window Pattern
Welcome to the Sliding Window Pattern concept lab. Maintain a window over a sequence and update state as the window moves. The must know points are: Fixed window has constant-size movement. Variable window grows and shrinks. Often used for substrings and subarrays. The common operations are: expand right, shrink left, update window state. The complexity shape is Usually O(n). Watch out for these pitfalls: Shrinking too late or too early. Not updating state when left moves. Related algorithms include Longest Substring Without Repeating Characters, Max Sum Subarray.
Concept details
Maintain a window over a sequence and update state as the window moves.
Must know
- Fixed window has constant-size movement.
- Variable window grows and shrinks.
- Often used for substrings and subarrays.
Complexity
Usually O(n)
1.0x