Files
kiskaadee 8a59b093b8
Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 8s
infra(validator): add DirectoryContract validation and migration manifest
2026-09-28 15:58:11 -05:00

26 lines
547 B
Python

from typing import ClassVar
class Solution:
SYMBOLS: ClassVar[dict[str, int]] = {
"I": 1,
"V": 5,
"X": 10,
"L": 50,
"C": 100,
"D": 500,
"M": 1000,
}
def romanToInt(self, s: str) -> int:
result = 0
values = self.SYMBOLS
current = values[s[0]]
for i in range(len(s) - 1):
following = values[s[i + 1]]
result += current * (-1 if following > current else 1)
current = following
return result + current