Java 0ms 32mb... beats 100%
Intuition:\nWe want to XOR N\'s binary with an array of 1\'s of the same length.\nApproach:\nFind out how long N is (via while loop.... 2^y=N).\nThen we subtrac
**Intuition:**\nWe want to XOR N\'s binary with an array of 1\'s of the same length.\n**Approach:**\nFind out how long N is (via while loop.... 2^y=N).\nThen we subtract 1 from our number, and we will get an array of 1\'s in binary.\n(ie. if x=2^8, then x-1 in binary is "1111 1111").\n\n\n\n```\nclass Solution {\n    public int bitwiseComplement(int N) {\n        if (N == 0) return 1;\n        if (N == 1) return 0;\n        int x = 1;\n        while(x<= N){\n             x = x << 1;  // equialently written as x*=2;\n        }\n        return N ^ (x-1);\n    }\n}\n```
[]