Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Convert Roman Numerals

Given a number in Roman numeral format, convert it to Arabic.

The values of Roman numerals are as follows:

{
  "M": 1000,
  "D": 500,
  "C": 100,
  "L": 50,
  "X": 10,
  "V": 5,
  "I": 1
}

In addition, note that the Roman numeral system uses subtractive notation for numbers such as IV and XL.

For the input "XIV", for instance, you should return 14.

More examples

Input: s = "III" Output: 3

Input: s = "LVIII" Output: 58

Input: s = "MCMXCIV" Output: 1994