Time: 0 ms (100%), Space: 18 MB (6.35%) - LeetHub

This commit is contained in:
Deven
2025-11-18 22:14:16 -05:00
parent 40b9ff2f98
commit 3ce5a0da95
@@ -0,0 +1,32 @@
class Solution:
def findComplement(self, num: int) -> int:
curr = num
comp = 0
pv = 0
while curr > 0:
if curr % 2 == 0:
comp += pow(2,pv)
pv += 1
curr = curr // 2
return comp
"""
100
011
4, 1
2, 3
1, 6
101
010
5, 0, 2
2, 1, 1
1, 2
"""