0 ms C++ code without xor or not.
Basic idea is to find the smallest power of 2 idx that is larger than the input number num, and output the difference between idx and num . For example, input 5
Basic idea is to find the smallest power of 2 `idx` that is larger than the input number `num`, and output the difference between `idx` and `num` . For example, input `5 (101)` , the smallest power of 2 (and larger than `5`) is `8 (1000)`, the output should be `8 - 5 - 1 = 2 (010)`. \n\n```\nclass Solution {\npublic:\n    int findComplement(int num) {\n        int idx = 2, tmp = num;\n        \n        while(tmp>>1) {\n            tmp >>= 1;\n            idx <<= 1;\n        }\n        \n        return idx - num - 1;\n    }\n};\n```
[]