Skip to content

Helper structures

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

1 guides12 min in totalAlgorithms

The guides, in order

Read them top to bottom: each one builds on the ones before. The ones you've read carry a check.

About this group

What you'll find
When to use a stack for whatever is still open, like unclosed brackets, and a ring buffer to keep the last k values.
It's for you if…
you see bracket problems, "next greater element" or windows of recent values and don't recognise the pattern.
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.