Hashing and Hash Tables Questions

How hash tables and hash-based structures work internally, and how to reason about their performance and correctness. Covers hash function properties (determinism, uniform distribution, speed, avalanche effect), cryptographic versus non-cryptographic hash choices, collision resolution (separate chaining, open addressing: linear probing, quadratic probing, double hashing, Robin Hood hashing, cuckoo hashing), load factor and amortized-cost resizing, and what makes an object hashable (the __hash__/__eq__ contract, immutability, custom composite keys). Covers hash-map-backed cache design (LRU and LFU eviction, TTL) and thread-safe concurrent hash maps (lock striping, CAS-based updates, safe concurrent resizing). Also covers hash-based structures beyond arrays and strings: consistent hashing for distributed routing and sharding, hash joins, hash-flooding and algorithmic-complexity security attacks and their mitigations, and probabilistic membership/cardinality structures such as Bloom filters, Cuckoo filters, Count-Min Sketch, and HyperLogLog. Excludes using a hash map purely as an optimization trick inside an array or string problem (two-sum, group anagrams, longest substring without repeating characters); that pattern belongs to Arrays, Strings, and Hashing. This topic is about the hash table itself: how it is built, how it fails under skewed or adversarial input, and how it scales.

HardSystem Design
55 practiced

Extend an LRU cache design to support per-entry TTL (time-to-live) and safe concurrent reads/writes from multiple threads. Describe the data structures, locking or sharding strategies to minimize contention, eviction rules when TTL expires, and how to handle race conditions between expiry and access.

EasyTechnical
74 practiced

You're implementing membership checks for a user ID blacklist that receives thousands of queries per second. Compare using a hash set versus a sorted array with binary search for membership tests. Discuss time/space complexity, cache locality, update costs, and when to prefer each in a backend service.

MediumSystem Design
65 practiced

Design a caching layer for API responses in a microservice using a hash-based in-memory store. Explain what you would include in the cache key, how you would decide which entries to evict under memory pressure, how you would keep the cache from serving stale data, and how your approach changes once the service runs on multiple instances.

HardSystem Design
77 practiced

Design a consistent hashing scheme for sharding keys across cache nodes that supports node additions and removals with minimal remapping. Explain ring construction, virtual nodes (vnodes), lookup algorithm, how to handle replication and node heterogeneity, and how you would integrate this into an ingestion pipeline that routes writes and reads.

EasyTechnical
58 practiced

Describe an approach to detect duplicates in a high-volume streaming feed of user events using hash-based structures. Include memory considerations, approximate alternatives (e.g., Bloom filters), and strategies for time-bounded duplicate detection (for instance, dedupe only within the last 24 hours).

Unlock Full Question Bank

Get access to all Hashing and Hash Tables interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.