[Java] Solution using Bit Manipulation
Maximum possible value to be stored = 1000000\nConsidering each bit of a number reprsents a number\nNumber of bits in one number(Numbers each number in the arra
Maximum possible value to be stored = 1000000\nConsidering each bit of a number reprsents a number\nNumber of bits in one number(Numbers each number in the array can represent) = 32\nTotal numbers required = 1000000/32 = 31250\nFor example:\nnumber 0 can be reprsented by idx = 0, bit = 0 i.e. num[0] = 00000000000000000000000000000001\nnumber 37 can be represented by idx = 1(37/32), bit = 5(37%32) ie. num[1] = 00000000000000000000000000100000\n```\nclass MyHashSet {\n    int num[];\n    public MyHashSet() {\n        num = new int[31251];\n    }\n\t\n\t// set the bit if that element is present\n    public void add(int key) {\n        num[getIdx(key)]|=getMask(key);\n    }\n\t\n\t//unset the bit if a key is not present\n    public void remove(int key) {\n        num[getIdx(key)] &= (~getMask(key));\n    }\n\t\n\t//check if bit corresponding to the key is set or not\n    public boolean contains(int key) {\n        return (num[getIdx(key)]&getMask(key))!=0;\n    }\n\t\n\t// idx of num[] to which this key belongs\n\t// for key = 37, it will give 1\n    private int getIdx(int key)\n    {\n        return (key/32);\n    }\n\t\n\t// get mask representing the bit inside num[idx] that corresponds to given key.\n\t// for key = 37, it will give 00000000000000000000000000100000\n    private int getMask(int key)\n    {\n        key%=32;\n        return (1<<key);\n    }\n}\n```
[]