Sliding Window & Two Pointers
Master the two most essential coding interview patterns. Learn fixed and variable sliding windows, basic and advanced two-pointer techniques, and hybrid approaches — all with complete Python solutions. These patterns appear heavily in streaming data processing and time series ML pipelines.
Your Learning Path
Follow these lessons in order, or jump to any topic that interests you.
1. Pattern Overview
When to use sliding window vs two pointers, template code for each pattern, and real-world ML applications in streaming data.
2. Fixed Size Window
5 classic problems: max sum subarray, average of subarrays, max in sliding window, string permutation check, and DNA sequences.
3. Variable Size Window
6 problems: minimum window substring, longest substring without repeats, longest repeating character replacement, and more.
4. Two Pointers Basic
5 problems: two sum sorted, container with most water, remove duplicates, move zeroes, and palindrome check.
5. Two Pointers Advanced
5 hard problems: 3Sum, trapping rain water, sort colors (Dutch National Flag), partition labels, and backspace string compare.
6. Combined & Hybrid
5 problems combining window + pointers: fruit into baskets, longest turbulent subarray, minimum window subsequence, and more.
7. Pattern Templates & Tips
Reusable template code for every pattern variant, a decision tree for choosing the right approach, and an FAQ accordion.
What You'll Learn
By the end of this course, you will be able to:
Recognize Patterns
Instantly identify when a problem requires sliding window, two pointers, or a hybrid approach based on the problem constraints.
Write Optimal Solutions
Implement O(n) solutions using template code that covers fixed windows, variable windows, and multi-pointer techniques.
Handle Edge Cases
Master tricky edge cases in substring problems, empty inputs, duplicate handling, and boundary conditions.
Apply to ML Pipelines
Use these patterns in real-world streaming data processing, time series feature extraction, and online learning systems.
Lilly Tech Systems