Description
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Given a roman numeral, convert it to an integer.
Examples
Input:
s = "III"Output:
3Explanation:
III = 3.
Input:
s = "LVIII"Output:
58Explanation:
L = 50, V= 5, III = 3.
Input:
s = "MCMXCIV"Output:
1994Explanation:
M = 1000, CM = 900, XC = 90 and IV = 4.
Constraints
- •
1 ≤ s.length ≤ 15 - •
s contains only the characters ('I', 'V', 'X', 'L', 'C', 'D', 'M'). - •
It is guaranteed that s is a valid roman numeral in the range [1, 3999].