Roman numeral to integer

Question

Given a Roman numeral string, write a function that returns the corresponding integer value. Keep in mind that Roman numerals also use subtractive notion, for example, IV corresponds to 4.

Below are the values for Roman numerals:

Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now