roman = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}


class Solution:

    def romanToInt(self, s):
        """
        :type s: str
        :rtype: int
        """
        ints = [roman[_] for _ in s]
        last = 1000
        total = 0
        for i in ints:
            total += i
            if i > last:
                total -= last + last
            last = i
        return total

1a080d9bf71409101b2041f4e9018ae387bf812e
<mask token>

<mask token>


class Solution:
    <mask token>

<mask token>


class Solution:

    def romanToInt(self, s):
        """
        :type s: str
        :rtype: int
        """
        ints = [roman[_] for _ in s]
        last = 1000
        total = 0
        for i in ints:
            total += i
            if i > last:
                total -= last + last
            last = i
        return total

roman = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}


class Solution:

    def romanToInt(self, s):
        """
        :type s: str
        :rtype: int
        """
        ints = [roman[_] for _ in s]
        last = 1000
        total = 0
        for i in ints:
            total += i
            if i > last:
                total -= last + last
            last = i
        return total
