[Java/Python] Basic HashTable implementation
If you know how HashTable works then it should be an easy problem. I believe that as a Software Engineer, understanding how HashTable works is a compulsory.\n- 
If you know how HashTable works then it should be an easy problem. I believe that as a Software Engineer, understanding how HashTable works is a compulsory.\n- To build HashTable, we need `bucket` as an static array to store elements which has the same bucket index:\n\t- The bucket index = hash_code(key) % BUCKET_SIZE\n\t- The larger BUCKET_SIZE is, the low chance collision happens.\n- To get a hash code of a integer value, we can use their value directly. But for other type like String, Object,... we need to write an efficient hash function to get the hash code which causes as low collision as possible.\n\n**Python 3**\n```python\nclass MyHashSet:\n\n    def __init__(self):\n        self.BUCKET_SIZE = 100\n        self.buckets = [[] for _ in range(self.BUCKET_SIZE)]\n\n    def add(self, key: int) -> None:\n        index = key % self.BUCKET_SIZE\n        if not self.contains(key):\n            self.buckets[index].append(key)\n\n    def remove(self, key: int) -> None:\n        index = key % self.BUCKET_SIZE\n        if self.contains(key):\n            self.buckets[index].remove(key)\n\n    def contains(self, key: int) -> bool:\n        index = key % self.BUCKET_SIZE\n        return key in self.buckets[index]\n```\n\n**Java**\n```java\nclass MyHashSet {\n\n    int BUCKET_SIZE = 100;\n    ArrayList[] buckets = new ArrayList[BUCKET_SIZE];\n\n    public MyHashSet() {\n        for (int i = 0; i < BUCKET_SIZE; ++i) {\n            buckets[i] = new ArrayList<>();\n        }\n    }\n\n    public void add(int key) {\n        if (contains(key)) return;\n        int bucketIndex = key % BUCKET_SIZE;\n        buckets[bucketIndex].add(key);\n    }\n\n    public void remove(int key) {\n        if (!contains(key)) return;\n        int bucketIndex = key % BUCKET_SIZE;\n        int idx = buckets[bucketIndex].indexOf(key);\n        buckets[bucketIndex].remove(idx);\n    }\n\n    public boolean contains(int key) {\n        int bucketIndex = key % BUCKET_SIZE;\n        return buckets[bucketIndex].contains(key);\n    }\n}\n```
[]