Roman to Integer

Easy
Strings String Hash Table Math

Convert a Roman numeral string to an integer. I=1, V=5, X=10, L=50, C=100, D=500, M=1000.

Constraints

1 ≤ s.length ≤ 15

Examples

Example 1:
Input: III
Output: 3
Example 2:
Input: LVIII
Output: 58
Explanation: L=50, V=5, III=3
Example 3:
Input: MCMXCIV
Output: 1994
Explanation: M=1000, CM=900, XC=90, IV=4
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.