27. Roman Numerals

Difficulty: 

Given a Roman numeral less than 4,000, convert it to a decimal number. This Wikipedia article describes Roman numerals in details, but here is a brief description:

Roman numerals consist of the following symbols:

A numeral is formed by a sequence of these symbols, where each symbol can be used up to 3 times to contribute to the total. Symbols are ordered left-to-right from larger to smaller, except for the following cases:

For example, 11 is XI, 98 is XCVIII, 99 is XCIX and 1944 is MCMXLIV.

Input:

romanToDecimal("MMXVI");

Output:

2016

Time Limit:

1000 (ms)

Hint (hover to see):

  • Hint #1



Results

ProblemsAcceptedWrongTimed OutError
200000

Input:

Expected Output:

Output: