LeetCode-476. Number Complement
时间:2017-01-20 12:46:11
收藏:0
阅读:355
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); } }
原文:http://www.cnblogs.com/wxisme/p/6322256.html
评论(0)