python use map and reduce


  • 0
    H

    class Solution(object):
    def titleToNumber(self, s):
    """
    :type s: str
    :rtype: int
    """
    def fn(x, y):
    return x * 26 + y
    def ordchar(chr):
    return ord(chr)-ord('A')+1

        return reduce(fn,map(ordchar,s))

Log in to reply
 

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