Roman To Integer

Convert a roman numeral to an integer.

Medium5/28/2024

Problem statement

Given a roman numeral as a string, convert it to an integer.

Examples:

  • III -> 3
  • IV -> 4
  • IX -> 9
  • LVIII -> 58
  • MCMXCIV -> 1994

The input is guaranteed to be a valid roman numeral in the range [1, 3999].

Problem leaderboard

#
Size
%
Users
#1
62 c.
Top 14%
sean
Steffan
#2
80 c.
Top 21%
helbling
#3
84 c.
Top 29%
XenThe
#4
87 c.
Top 36%
voytxt
#5
89 c.
Top 43%
Europe2048
#6
97 c.
Top 57%
Alex
smclaughlin-cf
#7
105 c.
Top 64%
SephQ
#8
106 c.
Top 79%
Thomasdcrt
maximec-indy
#9
132 c.
Top 86%
Mif712
#10
147 c.
Top 93%
madeforlosers
#11
195 c.
Top 100%
ComputerKWasTaken