add: 220104

This commit is contained in:
Lam Haoyin 2022-01-04 13:13:00 +08:00
parent 205f6c0419
commit 03734becc9
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
1 changed files with 12 additions and 0 deletions

12
2201/220104.cpp Normal file
View File

@ -0,0 +1,12 @@
#include <iostream>
class Solution {
public:
static int bitwiseComplement(int n) {
return n ? ((1 << ((31 ^ __builtin_clz(n)) + 1)) - 1) ^ n : 1;
}
};
int main() {
std::printf("%d\n", Solution::bitwiseComplement(0));
}