Design-Adjacent Problems
These are the highest-yield coding problems for Principal Architect interviews. Each connects to curriculum chapters and labs. Practice explaining aloud while writing pseudo-code — not silently grinding LeetCode.
Problem Bank
| # | Problem | Why principals see it | Curriculum link | Lab |
|---|---|---|---|---|
| 1 | Rate limiter | Every API platform | Distributed Rate Limiter | Lab 011 :8101 |
| 2 | Idempotent POST handler | Payments, workflows | Idempotency | Lab 008 :8081 |
| 3 | LRU cache | CDN, feed, session | Caching Fundamentals | — |
| 4 | Consistent hashing | Sharding, Dynamo-style | Distributed Caching | Lab 001 :8096 |
| 5 | Autocomplete / top-K | Search boxes | Search Autocomplete | — |
| 6 | URL shortener encode/decode | Base62, collision | URL Shortener | — |
| 7 | Producer-consumer queue | Backpressure, streaming | Message Delivery Semantics | Lab 006 :8094 |
| 8 | Merge K sorted streams | Log aggregation | Logging Platform | — |
| 9 | Interval merge / meeting rooms | Scheduling, capacity | Workflow Engine | — |
| 10 | Serialize / deserialize tree or graph | API payloads | REST, gRPC, and GraphQL | — |
| 11 | Thread-safe counter / metrics | Observability | Metrics Platform | — |
| 12 | Detect cycle in linked structure | Poison messages, refs | Sagas | Lab 010 :8093 |
Deep Dive: Rate Limiter (Token Bucket)
Prompt: Implement a rate limiter: max 100 requests per minute per client_id.
Clarify:
- Per-process or distributed? (Assume single-node first, then extend to Redis)
- Burst allowed? (Token bucket vs fixed window)
- What HTTP status on reject? (429 +
Retry-After)
Pseudo-code sketch:
class TokenBucket:
def __init__(self, rate_per_sec: float, burst: int):
self.rate = rate_per_sec
self.capacity = burst
self.tokens = burst
self.last_refill = now()
def allow(self) -> bool:
self._refill()
if self.tokens >= 1:
self.tokens -= 1
return True
return False
def _refill(self):
elapsed = now() - self.last_refill
self.tokens = min(self.capacity, self.tokens + elapsed * self.rate)
self.last_refill = now()
Principal follow-ups:
- Race conditions if multiple threads? → lock or atomic compare-and-swap
- Distributed? → Redis
INCR+ TTL or centralized token service - Hot key on celebrity client? → local shard of limit state
Deep Dive: Idempotent API Handler
Prompt: POST /charges with header Idempotency-Key. Duplicate keys must return the same response without double-charging.
Core logic:
- Lookup
(tenant_id, idempotency_key)in store - If
completed→ return cached response - If
in_progress→ return 409 or poll - Else insert
in_progress, process, store result, markcompleted
Link: Stripe Payment Idempotency scenario.
Deep Dive: Consistent Hashing
Prompt: Given N servers and string keys, route key to server; add/remove server with minimal remapping.
Signals:
- Virtual nodes for balance
- O(log N) lookup with sorted ring
- Know remapping fraction ≈ 1/N on add/remove
Lab: Consistent hashing on :8096
Deep Dive: Autocomplete
Prompt: Given prefix, return top 5 suggestions by frequency.
Approaches:
| Approach | Tradeoff |
|---|---|
| Trie + heap per node | Fast prefix, memory heavy |
| Elasticsearch / prefix index | Production realistic |
| Sorted array + binary search | Simple, poor for updates |
Principal angle: discuss incremental indexing and staleness — not just trie traversal.
Complexity Cheat Sheet
| Problem | Time | Space | Notes |
|---|---|---|---|
| Rate limiter (single node) | O(1) per request | O(clients) | Ring or map of buckets |
| LRU cache | O(1) get/put | O(capacity) | Hash map + doubly linked list |
| Consistent hash lookup | O(log V) | O(V) virtual nodes | V = virtual nodes |
| Merge K sorted | O(N log K) | O(K) | Min-heap |
| Autocomplete trie | O(L + K log K) | O(total chars) | L = prefix length |
Practice Format (45 min)
| Phase | Time | Activity |
|---|---|---|
| Clarify | 5 min | Requirements, constraints, API shape |
| Approach | 5 min | Data structures, complexity, tradeoffs |
| Implement | 20 min | Core path in pseudo-code or language |
| Test | 5 min | Normal, edge, failure cases |
| Extend | 10 min | Scale, distribution, observability |
Anti-Patterns in Principal Coding Rounds
| Anti-pattern | Why it fails |
|---|---|
| Silent coding for 15+ minutes | Panel cannot calibrate; looks like Staff, not Principal |
| Ignoring idempotency on mutations | Shows gap between code and production |
| No mention of tests | Principal owns quality bar |
| Over-optimizing obscure DP | Wrong signal for architecture roles |
Related
Interview + Game Day readiness
Coding prep includes Idempotency + rate limit patterns tied to production patterns. Targets the Production LLD and Game Day Standard at interview depth—connect leadership and prep chapters to production reasoning and tabletop game days.
Game Day tabletop drills
| Drill | Inject | Detect | Mitigate | Verify |
|---|---|---|---|---|
| GD-CP-1 | 'What if Redis dies?' | Verbal fallback | DLQ / degrade path | Correctness preserved |
| GD-CP-2 | Hot partition inject | Candidate detects | Consistent hashing | Throughput restored |