16. Roman to Number
easystringmath
Convert a valid Roman numeral to an integer. The symbols are I=1, V=5, X=10, L=50, C=100, D=500, M=1000. A smaller symbol placed before a larger one is subtracted (for example IV = 4 and CM = 900).
Example 1
Inputs = "III"
Output3
Example 2
Inputs = "LVIII"
Output58
Example 3
Inputs = "MCMXCIV"
Output1994
Constraints
- 1 ≤ s.length ≤ 15
- 1 ≤ value ≤ 3999