Another way 2 lines python code


  • 0
    class Solution(object):
        def climbStairs(self, n):
            fab = lambda n: reduce(lambda x, y: x * y, xrange(1, n + 1), 1) if n else 1
            return sum(fab(n - i) / fab(i) / fab(n - i * 2) for i in xrange(n / 2 + 1)) if n else 0

  • 0

    You could also use fab = math.factorial.


Log in to reply
 

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