Submission Detail

3999 / 3999 test cases passed.
Status:

Accepted

Runtime: 16 ms
Memory Usage: 44 MB
Submitted: 1 week, 3 days ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

0.0
2.5
5.0
7.5
10.0
12.5
15.0
17.5
20.0
22.5
25.0
5
10
15
20
25
java
You are here!
Your runtime beats 7.82 % of java submissions.
Runtime (ms)
Distribution (%)

0.0
2.5
5.0
7.5
10.0
12.5
15.0
17.5
20.0
22.5
25.0
10
20
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

41500
41750
42000
42250
42500
42750
43000
43250
43500
43750
44000
1
2
3
4
5
6
java
You are here!
Your memory usage beats 10.48 % of java submissions.
Memory (KB)
Distribution (%)

41500
41750
42000
42250
42500
42750
43000
43250
43500
43750
44000
2
4
6
Zoom area by dragging across this chart

Invite friends to challenge Integer to Roman


Submitted Code: 1 week, 3 days ago

Language: java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class Solution {
public String intToRoman(int num) {
String rom = "";
if (num < 1 || num > 3999)
return "";
// the 1000s
while (num/1000 > 0) {
rom = rom + "M";
num -= 1000;
}
// 900
if (num / 900 > 0) {
rom = rom + "CM";
num -= 900;
}
// 500-800
if (num / 500 > 0) {
rom = rom + "D";
num -= 500;
}
// 400
if (num / 400 > 0) {
rom = rom + "CD";
num -= 400;
}
// 100-300
while (num / 100 > 0) {
rom = rom + "C";
num -= 100;
}
// 90
if (num / 90 > 0) {
rom = rom + "XC";
num -= 90;
}
// 50-80
if (num / 50 > 0) {
rom = rom + "L";
num -= 50;
}
// 40
if (num /40 > 0) {
rom = rom + "XL";
num -= 40;
}
// 10-30
while (num / 10 > 0) {
rom = rom + "X";
num -= 10;
}
// 9
if (num / 9 > 0) {
rom = rom + "IX";
num -= 9;
}
// 5-8
if (num /5 > 0) {
rom = rom + "V";
num -= 5;
}
// 4
if (num / 4 > 0) {
rom = rom + "IV";
num -= 4;
}
// 1-3
while (num > 0) {
rom = rom + "I";
num--;
}
System.out.println(rom);
return rom;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX