Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2ed674d

Browse files
added p216
1 parent da388f3 commit 2ed674d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

‎src/main/java/in/ashwanik/dcp/problems/p211_p240/p216/Solution.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ int convertRomanToDecimal(String roman) {
2424
}
2525
int result = 0;
2626
int index = 0;
27+
if (roman.length() == 1) {
28+
return map.get(roman.charAt(0));
29+
}
2730
while (index < roman.length()) {
2831
int current = map.get(roman.charAt(index));
2932
int next = map.get(roman.charAt(index + 1));

‎src/test/java/in/ashwanik/dcp/problems/p211_p240/p216/SolutionTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class SolutionTest {
88
@Test
99
void testRomanToDecimal() {
1010
Solution solution = new Solution();
11+
assertEquals(5, solution.convertRomanToDecimal("V"));
1112
assertEquals(4, solution.convertRomanToDecimal("IV"));
1213
assertEquals(40, solution.convertRomanToDecimal("XL"));
1314
assertEquals(14, solution.convertRomanToDecimal("XIV"));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /