TweakCode
Arrays and Stacks lessons

Course 01 · Orientation

Arrays and Stacks

Scan, count, window, LIFO

Walk arrays with one remembered fact, look things up with hash maps, move two pointers, keep unfinished work on a stack, and slide a window over a range.

Start with Arrays & Strings

The course journey

Build one family of skills at a time

Each technique is three short lessons, and each one builds on the lesson before it. A lesson walks through one problem step by step, then hands it to you along with a few more to solve on your own.

  1. 01Start here

    Arrays & Strings

    Index in O(1), scan once, write in place, and summarize from both ends. Everything else sits on this.

    1. Stage 1Single-Pass State TrackingCarry one running value (min, max, or best so far) through a scan1 Lesson · 3 Problems
    2. Stage 2In-Place Read & Write PointersMaintain a write boundary to filter or compact in O(1) space1 Lesson · 3 Problems
    3. Stage 3Prefix & Suffix SummariesCombine left and right passes to answer range or exclusion queries1 Lesson · 3 Problems
  2. 02Pro

    Hashing

    Sets and maps that answer "seen it?" in O(1). Most O(n²) loops end here.

    1. Stage 1

      Hash Set Lookup

    2. Stage 2

      Hash Map Complement Lookup

    3. Stage 3

      Grouping by Canonical Key

    Preview
  3. 03Pro

    Two Pointers

    Two indexes moving inward. Each move rules out options for good.

    1. Stage 1

      Opposite-Direction Pointers

    2. Stage 2

      Sorted Pair Search

    3. Stage 3

      Greedy Pointer Elimination

    Preview
  4. 04Pro

    Stack

    Last in, first out. Matching, nesting, and next-greater in one pass.

    1. Stage 1

      Last-In, First-Out Matching

    2. Stage 2

      Augmented Stack

    3. Stage 3

      Monotonic Stack

    Preview
  5. 05Pro

    Sliding Window

    A live range over a sequence, updated in O(1) as it moves.

    1. Stage 1

      Fixed-Size Sliding Window

    2. Stage 2

      Variable-Size Sliding Window

    3. Stage 3

      Budgeted Sliding Window

    Preview