package LeetCode.Java;

/**
 * Created by Vonzpf on 17/3/23.
 */
public class NumberComplement {
    public int findComplement(int num) {
        String binary = Integer.toBinaryString(num);
        int numberComplement = (int)((long)Math.pow(2, binary.length()) - 1 - num);
        return numberComplement;
    }
}

@@ -58,16 +58,709 @@
 23.%0A */%0A
+/**-------------------------Title---------------------------------%0A Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.%0A%0A Note:%0A The given integer is guaranteed to fit within the range of a 32-bit signed integer.%0A You could assume no leading zero bit in the integer%E2%80%99s binary representation.%0A%0A Example 1:%0A Input: 5%0A Output: 2%0A Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.%0A%0A Example 2:%0A Input: 1%0A Output: 0%0A Explanation: The binary representation of 1 is 1 (no leading zero bits), and its complement is 0. So you need to output 0.%0A */%0A
 public c

476.Number Complement