Design HashSet
Easy
Topics
Design a HashSet without using any built-in hash set libraries. Implement MyHashSet with add(key), contains(key) (returns whether the key is present), and remove(key).
Example 1
Input: operations = ["MyHashSet","add","add","contains","contains","add","contains","remove","contains"], values = [[],[1],[2],[1],[3],[2],[2],[2],[2]] Output: [null,null,null,true,false,null,true,null,false]
Constraints
- 0 <= key <= 10^6
- At most 10^4 calls to add, remove, and contains.
Run ⌘' · Submit ⌘⏎