Advanced Problem Solving and Revision

Lesson 20 of 20

Race two pointers to a pair summing to 20, slide a window under budget 9, then pocket the course complexity cheat-sheet.

The big picture

Course recap radar

The final sweep: two pointers converge, sliding windows glide, Kadane scans — the patterns that turn O(n²) hunts into single passes.

Two pointers

Start at both ends of sorted data; every comparison retires one pointer — 6 + 14 = 20 falls out in three moves.

Sliding window

Grow right each step, shrink left while the window breaks its rule — each index enters and leaves once.

Kadane in one pass

Best subarray sum: extend the running total or restart at a[i] — no nested loops anywhere.

The trick pool

Prefix sums make range queries O(1); running max and XOR singles round out the revision kit.

Pattern radar

Sorted pair hunt → two pointers; contiguous + constraint → window; best subarray → Kadane.