package leetcode;

/**
 * https://leetcode.com/problems/thousand-separator/
 */
public class Problem1556 {
    public String thousandSeparator(int n) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1556 prob = new Problem1556();
        System.out.println(prob.thousandSeparator(987)); // "987"
        System.out.println(prob.thousandSeparator(1234)); // "1.234"
        System.out.println(prob.thousandSeparator(123456789)); // "123.456.789"
        System.out.println(prob.thousandSeparator(0)); // "0"
    }
}

@@ -157,411 +157,535 @@
     
-// TODO%0A        return null
+String answer = %22%22;%0A        String s = %22%22 + n
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1556 prob = new Problem1556();%0A        System.out.println(prob.thousandSeparator(987)); // %22987%22%0A        System.out.println(prob.thousandSeparator(1234)); // %221.234%22%0A        System.out.println(prob.thousandSeparator(123456789)); // %22123.456.789%22%0A        System.out.println(prob.thousandSeparator(0)); // %220%22
+int i = s.length();%0A        for (; i - 3 %3E= 0; i -= 3) %7B%0A            String sub = s.substring(i - 3, i);%0A            if (answer.isEmpty()) %7B%0A                answer = sub;%0A            %7D else %7B%0A                answer = sub + %22.%22 + answer;%0A            %7D%0A        %7D%0A        if (i %3E 0) %7B%0A            if (answer.isEmpty()) %7B%0A                answer = s;%0A            %7D else %7B%0A                answer = s.substring(0, i) + %22.%22 + answer;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1566