Just one line in python


  • 0
    F

    class Solution(object):
    def romanToInt(self, s):
    """
    :type s: str
    :rtype: int
    """
    return s.count('M')*1000+s.count('C')*100+s.count('D')*500+s.count('X')*10+s.count('L')*50+s.count('I')*1+s.count('V')*5- s.count('CM')*200-s.count('CD')*200-s.count('XC')*20-s.count('XL')*20-s.count('IX')*2-s.count('IV')*2


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.