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.
20 STAGES
☆☆☆☆☆ Clear any 5 stages to beat this world, or all 20 for 100%.
EASY2:08Design HashSet
DesignLC 705▶ START
EASY2:08Design HashMap
DesignLC 706▶ START
MEDIUM2:04Min Stack
DesignLC 155▶ START
MEDIUM2:10Online Stock Span
Monotonic stackLC 901▶ START
EASY2:10Implement Queue using Stacks
DesignLC 232▶ START
MEDIUM2:11Design Circular Queue
DesignLC 622▶ START
MEDIUM2:11Snapshot Array
DesignLC 1146▶ START
MEDIUM2:00Binary Search Tree Iterator
DesignLC 173▶ START
MEDIUM1:57LRU Cache
Hash map + linked listLC 146▶ START
HARD2:08LFU Cache
DesignLC 460▶ START
MEDIUM2:01Insert Delete GetRandom O(1)
Hash mapLC 380▶ START
MEDIUM2:04Add and Search Words
TrieLC 211▶ START
HARD2:05Find Median from Data Stream
HeapLC 295▶ START
MEDIUM2:08Time Based Key-Value Store
Binary searchLC 981▶ START
HARD2:02Merge k Sorted Lists
HeapLC 23▶ START
MEDIUM2:07Design Twitter
HeapLC 355▶ START
EASY2:07Kth Largest Element in a Stream
HeapLC 703▶ START
EASY2:07Last Stone Weight
HeapLC 1046▶ START
MEDIUM2:05Detect Squares
Hash mapLC 2013▶ START
MEDIUM2:01K Closest Points to Origin
HeapLC 973▶ START