One line solution C++
\nclass Solution {\npublic:\n    int findComplement(int num) {\n        return (pow(2,floor(log2(num))+1)-1)-num;\n    }\n};\n\n\nHere, floor(log2(num))+1 gives
```\nclass Solution {\npublic:\n    int findComplement(int num) {\n        return (pow(2,floor(log2(num))+1)-1)-num;\n    }\n};\n```\n\nHere, **floor(log2(num))+1** gives us the number of bits in integer **num**.\nThe maximum value obtained with this number of bits is **pow(2,no of bits)-1**.\nWhen we **subtract from maximum value to the given input** will gives the complement of the given input.\n\nHope it helps:) \nHappy coding.
['Bit Manipulation', 'C++']