As reported: Goldman Sachs CoderPad round (2026): implement a custom HashMap with a constructor,
putandget(method signatures were provided). Also asked in a Superday algorithms/data-structures round (Engineering Associate, USA, 2025) along with core Java collections questions (lists, sets, hash maps).
Implement a hash map for integer keys and values without using a built-in hash table: put(key, value) inserts or updates, get(key) returns the value or -1, remove(key) deletes the key if present.
This is LeetCode 706 — Design HashMap.
Example 1
ops = ["MyHashMap","put","put","get","get","put","get","remove","get"], args = [[],[1,1],[2,2],[1],[3],[2,1],[2],[2],[2]]
-> [null,null,null,1,-1,null,1,null,-1]
Constraints: 0 ≤ key, value ≤ 10^6; at most 10^4 calls.
Code runner format: LeetCode's design format: the first line lists the calls (starting with the constructor MyHashMap), the second line their arguments; implement the class MyHashMap; the harness prints one JSON array with each call's result (null for calls that return nothing).