← Citadel Interview Insights

Citadel·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026

Summary

Citadel systems design round, focused on a single infrastructure problem that went deeper than I expected. The question sounded like a quick data structure chat but turned into a full design discussion about tradeoffs I hadn't fully thought through.

Questions Asked (1)

Q1

Design a token store that supports lazy deletion: tokens have expiration times, and on lookup you determine whether a token is still valid without proactively cleaning up expired entries. How do you structure this, and how does cleanup get amortized across operations?

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

I jumped straight to a hash map and felt good about it for about 30 seconds.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (read/write ratio, latency, memory constraints) and then propose a hash map storing token metadata (value, expiry timestamp). Explain that lookups check expiry and treat expired tokens as absent, while cleanup is amortized via probabilistic or incremental strategies like periodic sweeps or lazy deletion with a background thread. Discuss trade-offs between eager vs lazy cleanup and how to bound memory growth.

Pro tip: Mention that in a real system you'd combine lazy deletion with a bounded cleanup mechanism (e.g., sampling or a min-heap) to avoid unbounded memory growth, and that you'd monitor expired token ratio to tune cleanup frequency.

1. Clarify requirements and constraints

Ask about read/write patterns, token volume, acceptable latency, memory limits, and whether persistence or distribution is needed. This shapes the data structure and cleanup strategy.

2. Design core data structure

Use a hash map (or concurrent map) keyed by token ID, storing value and expiration timestamp. On lookup, compare current time to expiry; if expired, return invalid without deleting immediately.

3. Implement lazy deletion on lookup

When a lookup finds an expired token, optionally delete it then (lazy deletion) to free memory opportunistically. This spreads cleanup cost across reads.

4. Amortize cleanup with background or incremental sweeps

Add a periodic background job that samples or scans a portion of entries and removes expired ones, or use a min-heap of expirations to efficiently find expired tokens. This bounds memory without blocking reads.

5. Discuss trade-offs and scaling

Compare eager vs lazy cleanup: eager uses more CPU but keeps memory low; lazy is faster but risks memory bloat. For distributed systems, consider sharding and per-shard cleanup.

Key Points to Mention

  • Hash map with token ID as key and (value, expiry timestamp) as value.
  • Lookup checks expiry and returns invalid if expired; may delete lazily.
  • Amortized cleanup via periodic background sweeps or incremental sampling.
  • Use of min-heap or timing wheel to efficiently track expirations.
  • Trade-offs: memory vs CPU, latency impact, and complexity.
  • Concurrency considerations: thread-safe maps, locking, or lock-free structures.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.