Skip to main content

1009. Complement of Base 10 Integer

Python

class Solution:
def bitwiseComplement(self, n: int) -> int:
return int(
''.join([
'0' if i == '1' else '1'
for i in "{:b}".format(n)
]),
2
)