Leetcode 1054 Solution

This article provides solution to leetcode question 1054 (complement-of-base-10-integer)

https://leetcode.com/problems/complement-of-base-10-integer

Solution

class Solution:
    def bitwiseComplement(self, N: int) -> int:
        if N == 0:
            return 1

        m = 1
        while m <= N:
            m *= 2
        return m - N - 1