We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0a57372 commit fc3974eCopy full SHA for fc3974e
solution/012. Integer to Roman/Solution.java
@@ -0,0 +1,9 @@
1
+class Solution {
2
+ private final String[] M = {"", "M", "MM", "MMM"};
3
+ private final String[] C = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
4
+ private final String[] X = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
5
+ private final String[] I = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
6
+ public String intToRoman(int num) {
7
+ return M[num / 1000] + C[(num % 1000) / 100] + X[(num % 100) / 10] + I[num % 10];
8
+ }
9
+}
0 commit comments