package leetcode;

/**
 * https://leetcode.com/problems/complement-of-base-10-integer/
 */
public class Problem1012 {
    public int bitwiseComplement(int N) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1012 prob = new Problem1012();
        System.out.println(prob.bitwiseComplement(5)); // 2
        System.out.println(prob.bitwiseComplement(7)); // 0
        System.out.println(prob.bitwiseComplement(10)); // 5
    }
}

@@ -165,16 +165,26 @@
     
-// TODO%0A
+if (N == 0) %7B%0A    
     
@@ -198,289 +198,281 @@
 urn 
-0
+1
 ;%0A    
-%7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1012 prob = new Problem1012();%0A        System.out.println(prob.bitwiseComplement(5)); // 2%0A        System.out.println(prob.bitwiseComplement(7)); // 0%0A        System.out.println(prob.bitwiseComplement(10)); // 5
+    %7D%0A        int n = N;%0A        int size = 0;%0A        while (n %3E 0) %7B%0A            n %3E%3E= 1;%0A            size++;%0A        %7D%0A        int answer = ~N;%0A        int m = ~0;%0A        for (int i = 0; i %3C size; i++) %7B%0A            m %3C%3C= 1;%0A        %7D%0A        return answer & ~m;
 %0A   

Solve problem 1012