0705. Design HashSet
https://leetcode.com/problems/design-hashset
Description
Design a HashSet without using any built-in hash table libraries.
Implement MyHashSet
class:
void add(key)
Inserts the valuekey
into the HashSet.bool contains(key)
Returns whether the valuekey
exists in the HashSet or not.void remove(key)
Removes the valuekey
in the HashSet. Ifkey
does not exist in the HashSet, do nothing.
Example 1:
Constraints:
0 <= key <= 106
At most
104
calls will be made toadd
,remove
, andcontains
.
ac
Last updated