Seperate Chaining. Collision Resolution. FAST AND NEAT!!
PLEASE UPVOTE IF FOUND USEFUL!!!\n\n\npublic class MyHashSet {\n\n\n    LinkedList<Integer>[] bucketList;\n    int capacity = 0; \n    int initialCapacity = 409
**PLEASE UPVOTE IF FOUND USEFUL!!!**\n```\n\npublic class MyHashSet {\n\n\n    LinkedList<Integer>[] bucketList;\n    int capacity = 0; \n    int initialCapacity = 4091;  //prime number\n\n    /**\n     * Initialize your data structure here.\n     */\n    public MyHashSet() {\n        this.bucketList = new LinkedList[initialCapacity];\n    }\n\n\n    public void add(int key) {\n        if (contains(key) == false) {\n            int index = hashValue(key, bucketList.length);\n            if (bucketList[index] == null) {\n                LinkedList<Integer> integerLinkedList = new LinkedList<>();\n                integerLinkedList.add(key);\n                bucketList[index] = integerLinkedList;\n\n            } else {\n                //collision\n                LinkedList<Integer> bucket = bucketList[index];\n                bucket.addLast(key);\n\n            }\n            capacity++;\n        } else {\n            //System.out.println("key is already present in Bucket= " + key);\n        }\n    }\n\n    public void remove(int key) {\n        int index = hashValue(key, bucketList.length);\n        if (bucketList[index] != null) {\n            bucketList[index].removeFirstOccurrence(key);\n        } else {\n            //System.out.println("key notremove present + key remove+" + key);\n        }\n\n    }\n\n \n\n    private int hashValue(int key, int bucketSize) {\n        return key % bucketSize;\n    }\n\n    /**\n     * Returns true if this set contains the specified element\n     */\n    public boolean contains(int key) {\n        int index = hashValue(key, bucketList.length);\n        if (bucketList[index] == null) {\n            return false;\n        } else {\n            LinkedList<Integer> linkedList = bucketList[index];\n            return linkedList.contains(key);\n        }\n\n    }\n}\n\n\n```
['Hash Function', 'Java']