package leetcode;

/**
 * https://leetcode.com/problems/base-7/
 */
public class Problem504 {
    public String convertToBase7(int num) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem504 prob = new Problem504();
        System.out.println(prob.convertToBase7(100)); // 202
        System.out.println(prob.convertToBase7(-7)); // -10
    }
}

@@ -143,16 +143,28 @@
     
-// TODO%0A
+if (num == 0) %7B%0A    
     
@@ -178,230 +178,445 @@
 urn 
-null
+%220%22
 ;%0A    
-%7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem504 prob = new Problem504();%0A        System.out.println(prob.convertToBase7(100)); // 202%0A        System.out.println(prob.convertToBase7(-7)); // -10
+    %7D%0A        StringBuilder result = new StringBuilder();%0A        boolean negative = false;%0A        if (num %3C 0) %7B%0A            num *= -1;%0A            negative = true;%0A        %7D%0A        while (num %3E 0) %7B%0A            result.append(num %25 7);%0A            num /= 7;%0A        %7D%0A        if (negative) %7B%0A            result.append(%22-%22);%0A            return result.reverse().toString();%0A        %7D%0A        return result.reverse().toString();
 %0A   

Solve problem 504