Easy
Quiz
#13 Roman to Integer
APPROACH
Roman numerals use seven symbols: I=1, V=5, X=10, L=50, C=100, D=500, M=1000. A symbol of lesser value immediately before one of greater value is subtracted; otherwise it is added. Convert the given Roman numeral string to its integer value.
Example 1:
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
Example 2:
Input: s = "III"
Output: 3
Explanation: III = 3.
Example 3:
Input: s = "LVIII"
Output: 58
Explanation: L = 50, V= 5, III = 3.
Example 4:
Input: s = "MCMXCIV"
Output: 1994
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
1 of 4
1:00
What is the optimal approach for this problem?