[LeetCode] 476. Number Complement
Python
class Solution:
def findComplement(self, num: int) -> int:
binary = bin(num)[2:]
answer = ''
for i in binary:
if i == '0':
answer += '1'
else:
answer += '0'
return int(answer, 2)
댓글남기기