Java simple, short and easy solution, 0 ms - faster than 100%
\nclass Solution {\n    int countDigits(int n) {\n        if (n == 0)\n            return 0;\n        return 1 + countDigits(n>>1);\n    }\n    \n    public int
```\nclass Solution {\n    int countDigits(int n) {\n        if (n == 0)\n            return 0;\n        return 1 + countDigits(n>>1);\n    }\n    \n    public int bitwiseComplement(int N) {\n        if (N == 0) return 1;\n        return (int)Math.pow(2, countDigits(N)) - 1 - N;\n    }\n}\n```\n**Like it? please upvote...**
['Java']