Skip to content

Commit c2c8dc6

Browse files
committed
Time: 42 ms (9.65%), Space: 16.6 MB (14.64%) - LeetHub
1 parent 6efde42 commit c2c8dc6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# time complexity: O(1)
2+
# space complexity: O(1)
3+
class Solution:
4+
def findComplement(self, num: int) -> int:
5+
bit = 1
6+
while num >= bit:
7+
num ^= bit
8+
bit <<= 1
9+
return num
10+
11+
num = 5
12+
print(Solution().findComplement(num))

0 commit comments

Comments
 (0)