Arrays & Strings: Two Pointers & Sliding Window

Subject: Data Structures & Algorithms Last updated: Jul 14, 2026

The Sliding Window Pattern

The sliding window is an indispensable technique for array/string problems, reducing nested loops to a single linear pass (O(N) time complexity). It is highly favored in Google and Amazon interviews.

Key Concepts

  • Fixed Window: The window size remains constant (e.g., "Find max sum of subarray of size K").
  • Dynamic Window: The window size expands and contracts based on a condition (e.g., "Smallest subarray with sum >= S").

Common Interview Questions

  1. Longest Substring Without Repeating Characters
  2. Minimum Window Substring
  3. Permutation in String