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:3
Explanation:

III = 3.

Input:s = "LVIII"
Output:58
Explanation:

L = 50, V= 5, III = 3.

Input:s = "MCMXCIV"
Output:1994
Explanation:

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].

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!