Python ✅✅✅ || 5-line Faster than 98.91% || Memory Beats 96.46%
Code\n\nclass Solution:\n    def bitwiseComplement(self, n: int) -> int:\n        b = bin(n)[2:]\n        b = b.replace(\'1\', \'_\')\n        b = b.replace(\'0
# Code\n```\nclass Solution:\n    def bitwiseComplement(self, n: int) -> int:\n        b = bin(n)[2:]\n        b = b.replace(\'1\', \'_\')\n        b = b.replace(\'0\', \'1\')\n        b = b.replace(\'_\', \'0\')\n        return int(b, 2)\n```\n![image.png](https://assets.leetcode.com/users/images/e94d9b3b-e0d2-416f-a545-4cd958b81ef3_1671167402.1350152.png)\n![image.png](https://assets.leetcode.com/users/images/2d830ee6-7485-45aa-a4c3-19a332292c2d_1671167378.0733662.png)\n
['Python3']