


Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
3 is written as III in Roman numeral, just three ones added together. 13 is written as XIII, which is simply X + III. The number 25 is written as XXV, which is XX + V
The first line contains a string ‘roman’ representing the number's roman number representation.
The only line contains a single integer denoting the integer value of the given roman number.
Do not print anything, just return an integer denoting the equivalent integer of the given roman number
It is guaranteed that the string input is one of the characters of I, V, X, L, C, D, M.
It is guaranteed that the integer value of the given roman number will not exceed 3999.
The key idea is to follow the rules of roman numbers which are as follows:
Keeping the above example in mind, we can write the following recursive solution:
The key idea is to follow the rules of roman numbers which are as follows:
Keeping the above example in mind, we can proceed in the following manner: