Objective
Master the sliding window pattern and solve all problems from the RisingBrain DSA sheet.
References
Pattern Description
Maintain a window of fixed or variable size. Expand the right pointer, shrink the left pointer when a constraint is violated. Avoids nested loops by reusing computation from the previous window.
- Fixed size: window length k, slide across (max sum, distinct elements)
- Variable size: expand/shrink to satisfy a condition (longest substring, minimum subarray)
Nedbank VAS Relevance
Q70 (Optimizing Resource Allocation): fixed-size window of length k, all elements unique, return max sum.
Sub-issues
| # |
Problem |
Difficulty |
| 1 |
Maximum Sum Subarray of Size K |
Easy |
| 2 |
Max Consecutive Ones |
Easy |
| 3 |
Max Consecutive Ones III |
Medium |
| 4 |
Subarray Product Less Than K |
Medium |
| 5 |
Fruits Into Baskets |
Medium |
| 6 |
Minimum Size Subarray Sum |
Medium |
| 7 |
Sliding Window Maximum |
Hard |
| 8 |
Subarray with K Distinct Integers |
Hard |
Notes
Language: Java
Objective
Master the sliding window pattern and solve all problems from the RisingBrain DSA sheet.
References
Pattern Description
Maintain a window of fixed or variable size. Expand the right pointer, shrink the left pointer when a constraint is violated. Avoids nested loops by reusing computation from the previous window.
Nedbank VAS Relevance
Q70 (Optimizing Resource Allocation): fixed-size window of length k, all elements unique, return max sum.
Sub-issues
Notes
Language: Java