package leetcode;

/**
 * https://leetcode.com/problems/encode-number/
 */
public class Problem1256 {
    public String encode(int num) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1256 prob = new Problem1256();
        System.out.println(prob.encode(8)); // "001"
        System.out.println(prob.encode(23)); // "1000"
        System.out.println(prob.encode(107)); // "101100"
    }
}

@@ -143,35 +143,571 @@
     
-// TODO%0A        return null
+String answer = %22%22;%0A        int n = 1;%0A        int i = 1;%0A        outer:%0A        while (true) %7B%0A            for (int j = 0; j %3C Math.pow(2, n) && i %3C= num; j++) %7B%0A                if (i == num) %7B%0A                    answer = Integer.toBinaryString(j);%0A                    int length = answer.length();%0A                    for (int k = 0; k %3C n - length; k++) %7B%0A                        answer = %220%22 + answer;%0A                    %7D%0A                    break outer;%0A                %7D%0A                i++;%0A            %7D%0A            n++;%0A        %7D%0A        return answer
 ;%0A  
@@ -798,24 +798,76 @@
 blem1256();%0A
+        System.out.println(prob.encode(4)); // %2201%22%0A
         Syst
@@ -958,24 +958,24 @@
 ; // %221000%22%0A
-
         Syst
@@ -1016,20 +1016,108 @@
 // %22101100%22%0A
+        System.out.println(prob.encode(1000000000)); // %2211011100110101100101000000001%22%0A
     %7D%0A%7D%0A

Update problem 1256