Leetcode 1006. Clumsy Factorial

class Solution(object):
    def clumsy(self, N):
        """
        :type N: int
        :rtype: int
        """
        op = {0: '*', 1: '//', 2: '+', 3: '-'}
        strN = list(map(str, range(N - 1, 0, -1)))
        ret = str(N)
        for i, s in enumerate(strN):
            ret += op[i % 4] + s
        return eval(ret)

猜你喜欢

转载自www.cnblogs.com/zywscq/p/10625183.html
今日推荐