package leetcode;

/**
 * https://leetcode.com/problems/number-complement/
 */
public class Problem476 {
    public int findComplement(int num) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem476 prob = new Problem476();
        System.out.println(prob.findComplement(5)); // 2
        System.out.println(prob.findComplement(1)); // 0
    }
}

@@ -151,24 +151,33 @@
     
-// TODO%0A
+if (num == 0) %7B%0A 
         
 retu
@@ -176,112 +176,148 @@
     
+   
 return 
-0
+1
 ;%0A    
-%7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem476 prob = new Problem476()
+    %7D%0A        int result = 0;%0A        for (int i = 0; i %3C 32; i++) %7B%0A            if (num %3E%3E i == 0) %7B%0A                break
 ;%0A  
@@ -326,113 +326,129 @@
     
+ 
-System.out.println(prob.findComplement(5)); // 2%0A        System.out.println(prob.findComplement(1)); // 0
+   %7D%0A            int b = (num %3E%3E i) & 1;%0A            result %7C= ((b == 0) ? 1 : 0) %3C%3C i;%0A        %7D%0A        return result;
 %0A   

Solve problem 476