starter45 min · 2 steps
Track

Hash-map lookups, from Two Sum to O(n)

The single technique that turns most brute-force loops into linear-time solutions.

Why this track

The most common junior-interview footgun is a nested loop where a hash-map lookup would do. This track pulls together the problems where the same pattern — remember what you've seen so far, check the complement — collapses O(n²) code into a single pass.

You'll leave with a reflexive habit: when the naive solution asks the same lookup question repeatedly, reach for a hash map before you reach for a second loop.

Progression

Follow the order

  1. 01
    problem
    Two Sum
    Given an array of integers and a target, return the indices of the two numbers that add up to the target.
    The canonical example. Understand why the hash map replaces the inner loop, not just how.
  2. 02
    article
    Why we run every code submission in a Firecracker microVM
    Every submission on ls-judge runs in its own Firecracker microVM — the same primitive AWS Lambda uses. Here is why we picked the hardware-isolation route over containers, and what it cost us to get there.
    Detour — how ls-judge itself isolates every submission. Skip if you're here for the pattern only.
Get started

Ready to start?