705. Design HashSet
Description
Design a HashSet without using any built-in hash table libraries.
Implement MyHashSet class:
void add(key)Inserts the valuekeyinto the HashSet.bool contains(key)Returns whether the valuekeyexists in the HashSet or not.void remove(key)Removes the valuekeyin the HashSet. Ifkeydoes not exist in the HashSet, do nothing.
Example 1:
1 | Input |
Constraints:
0 <= key <= 10^6- At most
10^4calls will be made toadd,remove, andcontains.
Hints/Notes
- 2025/03/20 Q2
- hash
- Leetcode solution
Solution
Language: C++
1 | class MyHashSet { |