MCPcopy Create free account
hub / github.com/Blankj/awesome-java-leetcode / intToRoman

Method intToRoman

src/com/blankj/medium/_0012/Solution.java:12–18  ·  view source on GitHub ↗
(int num)

Source from the content-addressed store, hash-verified

10 */
11public class Solution {
12 public String intToRoman(int num) {
13 String M[] = {"", "M", "MM", "MMM"};
14 String C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
15 String X[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
16 String I[] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
17 return M[num / 1000] + C[(num % 1000) / 100] + X[(num % 100) / 10] + I[num % 10];
18 }
19
20 public static void main(String[] args) {
21 Solution solution = new Solution();

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected