Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.
public class Solution { public int findComplement(int num) { return ~num & ((Integer.highestOneBit(num)<<1) - 1); } }
LeetCode-476. Number Complement
原文:http://www.cnblogs.com/wxisme/p/6322256.html