LeetCode-705. Design HashSet
问题描述
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 | Input |
Constraints:
0 <= key <= 106- At most
104calls will be made toadd,remove, andcontains.
解答
1 | /* |