Skip to content

Algorithms

The techniques behind most live coding problems. Explained from intuition, not from formulas.

6 guides3 groups66 min in total

  1. Search and sort

    Techniques for finding things fast: swapping a nested loop for a map, sorting first or halving the search space.

    About this group
    1. 1Nested Loops vs Maps and Sets: Trading Memory for Speed12 min
    2. 2Sort to Simplify: Turn Messy Input into a Single Pass11 min
    3. 3Binary Search: First True, Answer Spaces and Edge Cases12 min
  2. Pointer traversals

    Ways to walk an array or a string once by moving two indexes carefully. They solve many problems about pairs, subarrays and substrings.

    About this group
    1. 1Two Pointers: Skip Safely with an Invariant in O(1) Memory11 min
    2. 2Sliding window: contiguous runs in a single pass8 min
  3. Helper structures

    Simple data structures that keep track of pending work inside an algorithm.

    About this group
    1. 1Stacks and Ring Buffers: Open Items and the Last k Values12 min

About this section

What these guides are
Each guide covers one technique that shows up in many interview problems. The goal is for you to recognise when to use it, justify its cost and write it without hesitating. In the interview, that means you reach an efficient solution sooner and explain it better.
How they are organised
The techniques are grouped by the kind of work they do: searching and sorting, walking with pointers and leaning on helper structures. Within each group they go from the most basic to the ones that build on earlier ones.
How each guide works
Each guide starts with the intuition and the signs that tell you to use the technique, then the steps and its time and memory cost. It includes a step-by-step traced example, code in TypeScript, Python and PHP, variants, common mistakes and frequently asked questions.
Where to start
Start with maps and sets for O(1) lookups: it's the improvement most often expected over a first solution. Then go through the rest in order.