InterviewStack.io LogoInterviewStack.io

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
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).

MediumTechnical
79 practiced

You need to persist a large in-memory hash map to disk so it can be reloaded across restarts and code versions. Describe serialization formats (binary, protobuf, memory-mapped structures), strategies to handle hash-seed changes or changes in key classes, and how to ensure forward/backward compatibility and fast startup.

MediumTechnical
72 practiced

Design an online algorithm that processes a stream of characters and at any time can return the first non-repeating character seen so far. Describe the data structures you'd use and implement an online method next(char) that returns the current first non-repeating character or None. Discuss time and space complexity.

EasyTechnical
104 practiced

In Python, explain why some objects are unhashable (for example, lists and dicts). How can you safely use mutable or complex data as keys in a dictionary? Give examples and trade-offs, including freezing structures (frozenset/tuple), canonical serialization, or writing custom hash and eq methods.

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.