Java Solution with inner Bucket class!
I defined a inner bucket class to make the organization clean. Arrays are used to deal with the collision under the assumption that the number of buckets are al
I defined a inner bucket class to make the organization clean. Arrays are used to deal with the collision under the assumption that the number of buckets are always less than the key size. \n```\nclass MyHashSet {\n    class Buckets{\n        private int itemsNum;\n        private int items[];\n        \n        public Buckets(){\n            itemsNum = 1001;\n            items = new int[itemsNum];\n            init();\n        }\n        \n        public void init(){\n            for(int i = 0; i < itemsNum; i++)\n                items[i] = -1;\n        }\n        \n        public void setItem(int key,int value){\n            int index = hashItem(key);\n            items[index] = value;\n        }\n        \n        public int getItem(int key){\n            int index = hashItem(key);\n            return items[index];\n        }\n        public int hashItem(int key){\n            return key / bucketsNum;\n        }\n    }\n    \n    private int bucketsNum;\n    private Buckets buckets[];\n    /** Initialize your data structure here. */\n    public MyHashSet() {\n        bucketsNum = 1000;\n        buckets = new Buckets[bucketsNum];\n    }\n    \n    public int hashBucket(int key){\n        return key % bucketsNum;\n    }\n    public void add(int key) {\n        int bucketID = hashBucket(key);\n        if(buckets[bucketID] == null) buckets[bucketID] = new Buckets();\n        buckets[bucketID].setItem(key, key);\n    }\n    \n    public void remove(int key) {\n        int bucketID = hashBucket(key);\n        if(contains(key)) buckets[bucketID].setItem(key, -1);\n    }\n    \n    /** Returns true if this set contains the specified element */\n    public boolean contains(int key) {\n        int bucketID = hashBucket(key);\n        return buckets[bucketID] != null && buckets[bucketID].getItem(key) != -1;\n    }\n}\n```
[]