Menu

1 / 2

Mahdi Shamlou | Solving LeetCode #13: Roman to Integer— Step by Step

DEV Community: python·Mahdi SHamlou | مهدی شاملو·12 days ago
#It8kGbys
#devtopython#devto#dev#roman#value
Long article (1056 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.