Straightforward Python
This is not the shortest solution, but I believe straightforward solutions are more instructive.\n\nConsider the binary representation of the number.\nEvery 0 a
This is not the shortest solution, but I believe straightforward solutions are more instructive.\n\nConsider the binary representation of the number.\nEvery 0 at the ith position from the right. adds 2**i to the result.\n\n```\ndef findComplement(self, N):\n    binary = bin(N)[2:]\n    ans = 0\n    for i, u in enumerate(binary[::-1]):\n        if u == '0':\n            ans += 2 ** i\n    return ans\n```
[]