Build a hash set without the help of a ready-made hash table (do not use the set or dictionary type of your language).
Write a class MyHashSet with these methods:
add(key): put key in the set. If it is already there, nothing changes.
contains(key): return true if key is in the set, otherwise return false.
remove(key): take key out of the set. If it is not there, do nothing.
Examples
Example 1:
Input
["MyHashSet", "add", "add", "contains", "contains", "add", "remove", "contains", "remove"]
[[], [4], [8], [4], [6], [4], [8], [8], [6]]
Output
[null, null, null, true, false, null, null, false, null]
Explanation
add(4) and add(8) put two keys in the set.
contains(4) is true. contains(6) is false.
add(4) again changes nothing.
remove(8) takes 8 out, so contains(8) is false.
remove(6) does nothing, because 6 was never there.