C# solution using List-of-List
Solution 1: Array\n\nSince the problem\'s note explicitly says all values are in the range of [0, 1000000], one \'cheating\' solution is to have an array of siz
**Solution 1: Array**\n\nSince the problem\'s note explicitly says all values are in the range of [0, 1000000], one \'cheating\' solution is to have an array of size 1000001. Then Add(), Remove() and Contains() will all have O(1) time complexity. However, this solution is not practical in real projects.\n```\npublic class MyHashSet {\n    \n    private bool[] arr;\n\n    public MyHashSet() {\n        arr = new bool[1000001];\n    }\n\t\n    // O(1)\n    public void Add(int key) {\n        arr[key] = true;\n    }\n    \n\t// O(1)\n    public void Remove(int key) {\n        arr[key] = false;\n    }\n    \n\t// O(1)\n    public bool Contains(int key) {\n        return arr[key];\n    }\n}\n```\n\n**Solution 2: List of List**\n\nThis solution uses List-of-List as the underlying data structure and uses sperate chaining technique to solve hash collision issue. Add(), Remove() and Contains() all have O(n) time complexity.\n\nNote: Since the underlying data structure of List in C# is array, so Remove() and Contains() are both O(n) operations. In addition, there is no need to check the existence of an item when trying to remove it. Remove() will return false if the item is not found.\n\n```\npublic class MyHashSet {\n\n    private List<int>[] buckets;\n    private const int bucketSize = 769; // use prime number to minimize collision\n    \n    public MyHashSet() {\n        \n        buckets = new List<int>[bucketSize];\n        \n        for(int i = 0; i < bucketSize; i++)\n            buckets[i] = new List<int>();            \n    }\n    \n    // O(n)\n    public void Add(int key) {\n        \n        int hashCode = GetHashCode(key);\n        \n        if(!buckets[hashCode].Contains(key))\n            buckets[hashCode].Add(key);    \n    }\n    \n    // O(n)\n    public void Remove(int key) {\n        \n        int hashCode = GetHashCode(key);\n        \n        buckets[hashCode].Remove(key);   \n    }\n    \n    // O(n)\n    public bool Contains(int key) {\n        \n        int hashCode = GetHashCode(key);\n        \n        return buckets[hashCode].Contains(key);\n    }\n    \n    public int GetHashCode(int key)\n    {\n        return key % bucketSize;\n    }\n}\n```
[]