Cpp O(lgN) solution
\nclass Solution {\npublic:\n    int findComplement(int num) {\n        long long t=1;\n        while(t<=num)\n            t=t<<1;\n        return (t-1)^num;\n 
```\nclass Solution {\npublic:\n    int findComplement(int num) {\n        long long t=1;\n        while(t<=num)\n            t=t<<1;\n        return (t-1)^num;\n    }\n};\n```
[]