Layers of Logic

Data Structures & Algorithms · preview

Reason from the constraint to the algorithm.

Start with the structures that hold the data. Then learn four patterns by their movement rules, invariants, and failure cases—not by memorizing finished solutions.

Start with arrays
7 foundations4 complete pattern modules3 implementation languagesPreview more modules in development

Part 01

Foundations

Understand the operations and costs before choosing a pattern.

  1. 01ArrayA contiguous row of equal-sized slots. An index identifies a slot directly.Open →
  2. 02StringAn indexed sequence of characters, with immutability rules that depend on the language.Open →
  3. 03Hash MapA table that associates each unique key with one value.Open →
  4. 04Hash SetA hash table that records only whether a value is present.Open →
  5. 05StackA last-in, first-out collection: only the most recently added item is exposed.Open →
  6. 06QueueA first-in, first-out collection: new items join the back and leave from the front.Open →
  7. 07Linked ListA chain of nodes. Each node stores a value and a reference to the next node.Open →

Part 02

Problem-solving patterns

Recognition signals, invariants, implementation, complexity proof, and related problems.

  1. 01Two PointersUse two positions whose movement can eliminate choices without checking every pair.ArrayStringHash MapOpen →
  2. 02Sliding WindowMaintain a summary of one contiguous range while its boundaries move.ArrayStringHash MapHash SetOpen →
  3. 03Fast & Slow PointersUse either different speeds or a fixed gap to recover position information from a one-way chain.Linked ListHash SetOpen →
  4. 04Monotonic StackKeep unresolved positions in value order so a new item can answer several of them at once.ArrayStackOpen →

Not published yet

The next modules will appear only when their lessons are complete.

Merge Intervals, Binary Search on Answer, graph traversal, backtracking, heaps, and prefix sums remain in development.