Algorithm
Complement of Base 10 Integer
Solution
class Solution:
def bitwiseComplement(self, n: int) -> int:
if n == 0:
return 1
mask = 1
while mask < n:
mask = (mask << 1) | 1
return n ^ maskVideo GuideLeetcode Daily
Time Complexity
O(log N)
Space Complexity
O(1)
