0

Composite Data Structure Design

No single structure hits every bound, so combine them and keep the cross references in sync.

Design (LLD)O(1) amortised for most operationsNew26 problems
18
mastery

Trigger phrases

If a problem statement sounds like one of these, try this pattern first.

LRU cache
insert delete getRandom in O(1)
min stack
twitter feed

The template

Get this into muscle memory, then adapt the condition per problem.

// LRU: hash map for lookup + doubly linked list for recency
get(k) { const node = map.get(k); if (!node) return -1; moveToFront(node); return node.val; }
put(k, v) { /* evict tail when over capacity */ }

If you are stuck

The generic hint ladder for this pattern, in order.

  1. 1Write down the required time bound for each operation first.
  2. 2A hash map gives lookup, a list gives order. Use both.
  3. 3The hard part is keeping both views consistent on every mutation.

Drill it

Every problem in the bank that uses this pattern.

0 / 26 solved
1
MDesign (LLD)
2
MDesign (LLD)
3
MStacks & Queues
4
5
MDesign (LLD)
6
MBinary Search Tree
7
8
9
EDesign (LLD)
10
EHeap / Priority Queue
11
MDesign (LLD)
12
HDesign (LLD)
13
14
15
16
HDesign (LLD)
17
MDesign (LLD)
18
MDesign (LLD)
19
20
21
22
EDesign (LLD)
23
MIntervals
24
MDesign (LLD)
25
26