WORLD 9

DESIGN

Build your own data structure, with every operation in constant time: a stack that knows its minimum, a cache.

STAGE 0 Design tutorial

0:00 / 0:00

The move

You get a blueprint: a class with a few methods and a promised cost for each. Snap a helper part onto the plain data (a second value, a map from key to node, a heap) so every call stays fast.

Spot it
The problem says design or implement a class, and each method must run in O(1) or O(log n), often on average.
Cost
Fast calls are paid for with extra memory, usually one entry per item: O(n) space.

15 STAGES Design problems

☆☆☆☆☆ Clear 5 to finish this world.