Skip to content

Two Pointers

Problem Complexity Key Pattern
Container With Most Water O(n) Maximizing area/product with two boundaries — shrink from both ends,
Three Sum O(n^2) Reducing N-sum to 2-sum on a sorted array — "find triplets/k-tuples
Trapping Rain Water O(n) Bounded accumulation between barriers — water trapping, histogram