Design HashMap
Easy
Topics
Design a HashMap without using any built-in hash table libraries. Implement MyHashMap with put(key, value), get(key) (returns the value or -1 if the key is absent), and remove(key).
Example 1
Input: operations = ["MyHashMap","put","put","get","get","put","get","remove","get"], values = [[],[1,1],[2,2],[1],[3],[2,1],[2],[2],[2]] Output: [null,null,null,1,-1,null,1,null,-1]
Constraints
- 0 <= key, value <= 10^6
- At most 10^4 calls to put, get, and remove.
Run ⌘' · Submit ⌘⏎