dsa · easy
Design HashMap
GreyOrangeHash MapDesignFoundation
Implement MyHashMap for integer keys and values (no language dict required in an interview — buckets plus collision handling).
Methods
put(key, value)insert or overwriteget(key)→ the value, or-1if missingremove(key)delete if present (no-op if missing)
Fill in the MyHashMap class. The starter already walks ops / args and calls your methods — leave the driver at the bottom as-is. Constructors contribute null; booleans print as true / false.
**Example**
`` MyHashMap() → null put(1, 1) → null put(2, 2) → null get(1) → 1 get(3) → -1 put(2, 1) → null get(2) → 1 remove(2) → null get(2) → -1 ``
Constraints
Calls <= 1000, 0 <= key,value <= 10^6
Examples
Example 1
Input: ["MyHashMap","put","put","get","get","put","get","remove","get"] [[],[1,1],[2,2],[1],[3],[2,1],[2],[2],[2]] Expected: [null,null,null,1,-1,null,1,null,-1]