Python 4 lines: faster than 99%, memory less than 100%
\nclass Solution:\n    def bitwiseComplement(self, N: int) -> int:\n        P = 2\n        while P <= N:\n            P *= 2\n        return P - 1 - N\n\nIf P i
```\nclass Solution:\n    def bitwiseComplement(self, N: int) -> int:\n        P = 2\n        while P <= N:\n            P *= 2\n        return P - 1 - N\n```\nIf P is the smallest power of 2 larger than N, then N and its binary complement M satisfies N+M=P-1.
[]