diff --git a/Easy/13. Roman to Integer/Solution.py b/Easy/13. Roman to Integer/Solution.py new file mode 100644 index 0000000..2afd7df --- /dev/null +++ b/Easy/13. Roman to Integer/Solution.py @@ -0,0 +1,11 @@ +roman = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000} +class Solution: + def romanToInt(self, S: str) -> int: + summ= 0 + for i in range(len(S)-1,-1,-1): + num = roman[S[i]] + if 3*num < summ: + summ = summ-num + else: + summ = summ+num + return summ \ No newline at end of file