46. Roman to Integer
Easy
Convert a valid Roman numeral representation to an integer, using the symbols I, V, X, L, C, D and M. When a smaller symbol appears before a larger one, its value should be subtracted.
Example 1
Input: texto = "MCDLII"
Output: 1452
Explanation: M is 1000, CD is 400, L is 50, and II is 2.
Example 2
Input: texto = "XLIX"
Output: 49
Constraints
- 1 <= texto.length <= 15
- texto representa um número entre 1 e 3999.
StringsMath
Saved in this browser
Caso 1
texto =
"MCDLII"
Expected =
1452
Caso 2
texto =
"XLIX"
Expected =
49
Run checks these 2 cases. Submit runs all 6, including hidden ones.