How to Identify Sliding Window Problems:
- These problems generally require Finding Maximum/Minimum Subarray, Substrings which satisfy some specific condition.
- The size of the subarray or substring ‘K’ will be given in some of the problems.
- These problems can easily be solved in O(N2) time complexity using nested loops, using sliding window we can solve these in O(n) Time Complexity.
- Required Time Complexity: O(N) or O(Nlog(N))
- Constraints: N <= 106 , If N is the size of the Array/String.
Sliding Window Technique
Sliding Window problems are problems in which a fixed or variable-size window is moved through a data structure, typically an array or string, to solve problems efficiently based on continuous subsets of elements. This technique is used when we need to find subarrays or substrings according to a given set of conditions.
Table of Content
- What is Sliding Window Technique?
- How to use Sliding Window Technique?
- How to Identify Sliding Window Problems
- Use Cases of Sliding Window Technique
- Practice Problems on Sliding Window Technique