MODULE 07 · INTERMEDIATE

Array Algorithms: Prefix Sums, Two Pointers & Sliding WindowJava & Data Structures · Module 7

Master foundational algorithmic patterns on arrays: static range queries via Prefix Sums, opposite-end and fast/slow Two Pointers, and dynamic Sliding Windows.

4 lessons16 min readingAsymptotic Complexity, Linear Data Structures & Search
Free, self-paced, and open to everyone. No account needed.
WHAT THIS MODULE COVERS

Array Algorithms: Prefix Sums, Two Pointers & Sliding Window

Master foundational algorithmic patterns on arrays: static range queries via Prefix Sums, opposite-end and fast/slow Two Pointers, and dynamic Sliding Windows.

BEFORE YOU START

Array indexing and complexity analysis

WHAT YOU’LL BE ABLE TO DO

Mastery of prefix sums, two-pointer boundary scans, variable sliding windows, and Kadane's maximum subarray invariant.

THE LESSON SEQUENCE

Read in order, or jump to what you need.

Every lesson builds on the one before it. Open any lesson to read the explanation, run the examples, and try the practice challenges.

  1. 07.01
    Prefix Sums, Difference Arrays & O(1) Range Queries

    Transform O(N) range queries into O(1) lookups. Master 1D and 2D prefix sums, subarray sum equals K with HashMaps, and difference arrays for range updates.

    4 min
  2. 07.02
    The Two Pointers Pattern: Opposing Ends & Slow/Fast Collisions

    Master the two pointers technique. Contrast inward-converging pointers for sorted arrays (Two-Sum II, Container With Most Water) with fast/slow pointers for in-place array compaction.

    4 min
  3. 07.03
    The Sliding Window Pattern: Fixed vs Dynamic Windows

    Master the sliding window pattern. Contrast Fixed-Size windows (maximum sum subarray of size K) with Dynamic-Size windows (longest substring without repeating characters).

    4 min
  4. 07.04
    Maximum Subarray Invariants: Kadane's Algorithm and Circular Buffers

    Dissect dynamic programming invariants in continuous array problems, implementing Kadane's algorithm, tracking indices, and solving the maximum circular subarray problem.

    4 min
MODULE SELF-CHECK

Ready to move on?

Solve sliding window substring problems and circular maximum subarray problems in linear time.

Open the module self-check