13. Roman to Integer

Given a roman numeral, convert it to an integer.

Input is guaranteed to be within the range from 1 to 3999.

BASIC Character
I
V
X
L
C
D
M
Arabic numerals
1
5
10
50
100
500
1000

the rule is complex,but in this condition. It can be tell as:

we start from the end of String.
if the char before the current char we are reading: add it
if not: subtract it。

Code

Last updated

Was this helpful?