@@ -0,0 +1,1105 @@
+package fundamentals.string.lc012_integertoroman;%0A%0A/**%0A * Given an integer, convert it to a roman numeral.%0A * Input is guaranteed to be within the range from 1 to 3999.%0A */%0Apublic class Solution %7B%0A%0A    public String intToRoman(int num) %7B%0A        StringBuilder str = new StringBuilder();%0A%0A        String%5B%5D%5B%5D base = %7B%0A                %7B%22I%22, %22V%22, %22X%22%7D,%0A                %7B%22X%22, %22L%22, %22C%22%7D,%0A                %7B%22C%22, %22D%22, %22M%22%7D,%0A                %7B%22M%22, %22-%22, %22-%22%7D,%0A        %7D;%0A%0A        int i = 0;%0A        while (num %3E 0) %7B%0A            str.insert(0, parse(num %25 10, base%5Bi%5D%5B0%5D, base%5Bi%5D%5B1%5D, base%5Bi%5D%5B2%5D));%0A            num /= 10;%0A            i++;%0A        %7D%0A        return str.toString();%0A    %7D%0A%0A    // num: %5B0,9%5D%0A    private String parse(int num, String one, String five, String ten) %7B%0A        int mod = num %25 5;%0A        if (mod %3C= 3) %7B     // %5B0,3%5D =%3E 0~3, 5~8%0A            String str = %22%22;%0A            while (mod-- %3E 0) %7B%0A                str += one;%0A            %7D%0A            return num %3E= 5 ? five + str : str;%0A        %7D else %7B            // %5B4%5D =%3E 4,9%0A            return num %3E 5 ? one + ten : one + five;%0A        %7D%0A    %7D%0A%0A%7D%0A

leetcode-012 integer to Roman