C++ Simple to Understand HashSet Implementation
\nclass MyHashSet {\nprivate:\n    int numBuckets;\n    vector<list<int>> buckets;\n\n    int hash(int key)\n    {\n        return key % numBuckets;\n    }\n\np
```\nclass MyHashSet {\nprivate:\n    int numBuckets;\n    vector<list<int>> buckets;\n\n    int hash(int key)\n    {\n        return key % numBuckets;\n    }\n\npublic:\n    /** Initialize your data structure here. */\n    MyHashSet() \n    {\n        numBuckets = 15000;\n        buckets = vector<list<int>>(numBuckets, list<int>{});\n    }\n    \n    void add(int key) \n    {\n        int i = hash(key);\n        if(find(buckets[i].begin(), buckets[i].end(), key) == buckets[i].end())\n        { \n            buckets[i].push_back(key);\n        }\n    }\n    \n    void remove(int key) \n    {\n        int i = hash(key);\n        list<int>::iterator it = find(buckets[i].begin(), buckets[i].end(), key);\n        \n        if (it != buckets[i].end())\n        {\n            buckets[i].erase(it);\n        } \n    }\n    \n    /** Returns true if this set contains the specified element */\n    bool contains(int key)\n    {\n        int i = hash(key);\n        if(find(buckets[i].begin(), buckets[i].end(), key) == buckets[i].end())\n        {\n            return false;\n        }\n        else \n        {\n            return true;\n        }\n    }\n};\n```
[]