Skip to content

Commit c2b9728

Browse files
committed
28ms, 82%, 68%.
1 parent c7e9991 commit c2b9728

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

1009.complement-of-base-10-integer.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# @lc app=leetcode id=1009 lang=python3
3+
#
4+
# [1009] Complement of Base 10 Integer
5+
#
6+
7+
# @lc code=start
8+
9+
# Built-in Functions to Construct 1-bits Bitmask
10+
class Solution:
11+
def bitwiseComplement(self, n: int) -> int:
12+
if n == 0:
13+
return 1
14+
else:
15+
return (1 << n.bit_length())-n-1
16+
17+
# @lc code=end

0 commit comments

Comments
 (0)