Design HashMap
Problem Implement a HashMap without built-in hash tables: put(key, value), get(key), remove(key). Expect internal-workings probes — including why a large prime is used as the hash modulus.
Input / Output
- Operations on integer (or generic) keys; get returns -1 / absent for missing keys.
Constraints
- Ops up to 10^4; O(1) average per operation expected; collisions must be handled, not assumed away.
Example
- put(1, 10), put(1, 20) -> get(1) = 20 (upsert); remove(1) -> get(1) = -1.
asked …