C++ Solution using XOR
```\nclass Solution {\npublic:\n    int findComplement(int num) {\n        int count=0;\n        int j=num;\n        while(j!=0){\n            j=j/2;\n         
```\nclass Solution {\npublic:\n    int findComplement(int num) {\n        int count=0;\n        int j=num;\n        while(j!=0){\n            j=j/2;\n            count++;\n        }\n        int ans = pow(2,count) - 1;\n        return num ^ ans;\n    }\n};\n
[]