Read Roman Numerals

Roman numerals appear in dates, book chapters, and numbering systems, but programs usually need regular integers. Given a Roman numeral string s, return its integer value. If a smaller symbol comes before a larger one, subtract it instead of adding it.

Примеры

Ввод
"III"
Вывод
3
Ввод
"LVIII"
Вывод
58
Ввод
"MCMXCIV"
Вывод
1994

Нужно реализовать

def roman_to_int(s: str) -> int:

Теги

stringshashmapmath
PostgreSQLv16

Siia ilmub koodi käivituse tulemus

Visible tests
1
Input
"III"
Expected3
2
Input
"LVIII"
Expected58
3
Input
"MCMXCIV"
Expected1994
4
Input
"IV"
Expected4
5
Input
"IX"
Expected9
6
Input
"LVIIILVIII"
Expected100
Focus radio
Paused · SomaFM · Fluid