Simple Java solution | 0 ms beats 100% submissions
```\n  public int bitwiseComplement(int N) {\n        if(N==0)\n            return 1;\n        int count = 0;\n        int oldnum=  N;\n        \n        //coun
```\n  public int bitwiseComplement(int N) {\n        if(N==0)\n            return 1;\n        int count = 0;\n        int oldnum=  N;\n        \n        //count the num of digits in binary form for the given number\n        while(N > 0){\n            N >>=1;\n            count++;\n        }\n    \n        // generate a number with all digits as 1\n        int num =0;\n        while(count>0){\n            num = num <<1;\n            num = num|1;\n             count--;\n        }\n    // XOR will reverse the bits (e.g. 1010 ^ 1111 = 0101)\n        return num ^ oldnum;\n    }\n\t
['Bit Manipulation', 'Java']