Hey everyone! Mahdi Shamlou here — back with another LeetCode classic problem.
Today, we're going to solve LeetCode #13: Roman to Integer .
In the previous article, we solved LeetCode #12: Integer to Roman , where we converted an integer into a Roman numeral.
This time, we're going to do the opposite!
We are given a Roman numeral, and our task is to convert it into an integer.
Let's get started!
1. Understanding the Problem
We are given a string containing a Roman numeral, and we need to convert it into an integer.
Roman numerals use seven basic symbols:
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
But there is something important we need to understand.
Sometimes, a smaller value comes before a larger value.…