🔥 Easy C++ Solution With Explanation | Vector
\nclass MyHashSet {\n    \n    // store details of key k in k th index of array\n    vector<bool> ans;\npublic:\n    MyHashSet() {\n        \n        // max pos
```\nclass MyHashSet {\n    \n    // store details of key k in k th index of array\n    vector<bool> ans;\npublic:\n    MyHashSet() {\n        \n        // max possible value of key is 10^6 so array should be of length 10^6 + 1 \n        ans.resize(1e6+1,false);\n    }\n    \n\t// change presence of K th value of array to add or remove from hashset\n\t\n    void add(int key) {\n        ans[key] = true;\n    }\n    \n    void remove(int key) {\n        ans[key]=false;\n    }\n    \n\t// to check if present just return it\'s value at K th position\n    bool contains(int key) {\n        return ans[key];\n    }\n};\n```
['C', 'C++']