Number Complement LeetCode solution in C++

1
class Solution {
2
public:
3
int findComplement(int num) {
4
long n = 1;
5
while (n - 1 < num) {
6
n <<= 1;
7
}
8
n--;
9
return n - num;
10
}
11
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0