Advanced·Concept·2 min read

Sliding window and two pointers

Practice this question

Sliding window

Use when you need a contiguous subset of an array or string.

Problems to practice

  • Longest substring without repeating characters
  • Maximum sum subarray of fixed size
  • Minimum window substring
  • Fruits into baskets
  • Permutation in string

Two pointers

Use when you need to scan from both ends or move indices in different directions.

Problems to practice

  • Valid palindrome
  • Container with most water
  • Merge sorted arrays
  • Remove duplicates from sorted array

Adapted from 14_DSA_MASTER.md · “15. Sliding window and two pointers”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.