Two pointers

Problems on two pointers, including finding two numbers with a given sum in a sorted array, the longest or shortest window with a given property, merging sorted sequences, counting pairs with a bounded difference and the shortest substring that contains every required letter.

The two pointers article in the Basics section explains the technique. Related problem sets are under Sorting, Binary search and Prefix sums.

Problems