Java, simple 1 line bit manipulation (left & right shifts), 0ms
Just actually do the complement operation ~, after first shifting away all the leading zeroes, and then shift away all the trailing ones.\n\n    public int bitw
Just actually do the complement operation ~, after first shifting away all the leading zeroes, and then shift away all the trailing ones.\n```\n    public int bitwiseComplement(int N) {\n        return (N==0) ? 1 : (~(N<<(N=Integer.numberOfLeadingZeros(N))))>>N;\n    }\n```
[]