Leetcode 476 Solution
This article provides solution to leetcode question 476 (number-complement)
Access this page by simply typing in "lcs 476" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/number-complement
Solution
class Solution {
public:
int findComplement(int num) {
int a = 0;
while (a < num)
a = 2 * a + 1;
return a ^ num;
}
};