class Solution(object):

    def romanToInt(self, s):
        """
        :type s: str
        :rtype: int
        """
        rv = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
        num = 0
        for i in range(0, len(s)):
            if i + 1 < len(s) and rv[s[i]] < rv[s[i + 1]]:
                num = num - rv[s[i]]
            else:
                num += rv[s[i]]
        return num

e362194569013c82fd4e82b84f3036134a4e1260
<mask token>

class Solution(object):
    <mask token>

class Solution(object):

    def romanToInt(self, s):
        """
        :type s: str
        :rtype: int
        """
        rv = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
        num = 0
        for i in range(0, len(s)):
            if i + 1 < len(s) and rv[s[i]] < rv[s[i + 1]]:
                num = num - rv[s[i]]
            else:
                num += rv[s[i]]
        return num
