Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 820 Bytes

sliding_window_technique.md

File metadata and controls

27 lines (21 loc) · 820 Bytes

Sliding Window Technique

Sliding Window Technique is a method for finding subarray or substring of a given array or string in linear time O(n) by using two pointers technique.

Sliding Window Code Template

def sliding_window(s):
    left, right = 0, 0
    while right < len(s):
        # increase right pointer
        right += 1
        # update window
        ...
        while window needs shrink:
            # increase left pointer
            left += 1
            # update window
            ...

Sliding Window Technique Problems

Max Consecutive Ones Minimum Size Subarray Sum Remove Element