Roman to Integer - LeetCode Solution

Publicado em: 09 Julho 2022
no canal de: CodingWithKaushik
1,083
21

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000

For example, 2 is written as II in Roman numeral, just two ones added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.

Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:

I can be placed before V (5) and X (10) to make 4 and 9.
X can be placed before L (50) and C (100) to make 40 and 90.
C can be placed before D (500) and M (1000) to make 400 and 900.
Given a roman numeral, convert it to an integer.



Example :
Input: "LVIII"
Output: 58
Explanation: L = 50, V= 5, III = 3. 50+5+3 = 58


Code Files - https://github.com/CodingWithKaushik/...

Required knowledge
Basic JavaScript programming, If else, While loop


Disclaimer:
All videos are for educational purpose and use them wisely. Any video may have a slight mistake, please take decisions based on your research. This video is not forcing anything on you.

Video Course will be 100% free and will be released on YouTube. The playlist will be updated with new DS Based tutorial videos every week. The plan is to cover all the important concepts of DS & Algorithms.

Put your comments and share your experience with us if you like this video Also if you have some suggestions then please suggest them in the comment box.

Javascript
udemy javascript
javascript course
ES6

Thank's For Watching This Video
Like Share Subscribe


Nesta página do site você pode assistir ao vídeo on-line Roman to Integer - LeetCode Solution duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário CodingWithKaushik 09 Julho 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 1,083 vezes e gostou 21 espectadores. Boa visualização!