Skip to main content

One doc tagged with "array"

View all tags

Array scanning patterns — turning a nested loop into a single pass

This chapter organizes four patterns for reducing nested loops to a single pass by applicability. It covers two-pointer, sliding window (fixed and variable), prefix sum for range totals, monotonic stack for "next greater element", and the decision procedure for picking the right one.