Skip to content

Commit 1515da4

Browse files
authored
Update complement-of-base-10-integer.cpp
1 parent fe01dc3 commit 1515da4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

C++/complement-of-base-10-integer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
class Solution {
55
public:
66
int bitwiseComplement(int N) {
7-
int X = 1;
8-
while (N > X) {
9-
X = X * 2 + 1;
7+
int mask = 1;
8+
while (N > mask) {
9+
mask = mask * 2 + 1;
1010
}
11-
return X - N;
11+
return mask - N;
1212
}
1313
};

0 commit comments

Comments
 (0)