有想法,但是没有这个简练
Java,用到了库函数
public class Solution {
public int findComplement(int num) {
return ~num+(Integer.highestOneBit(num)<<1);
}
}
public class Solution {
public int findComplement(int num) {
return ~num+(Integer.highestOneBit(num)<<1);
}
}