题目
Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.
Example 1:
1 | Input: 5 |
Example 2:
1 | Input: 1 |
Note:
- The given integer is guaranteed to fit within the range of a 32-bit signed integer.
- You could assume no leading zero bit in the integer’s binary representation.
- This question is the same as 1009.
思路
Easy题,按题目要求操作即可,没什么好说的打个卡而已。。。
代码
1 | class Solution(object): |