aboutsummaryrefslogblamecommitdiffstats
path: root/70/main.py
blob: d0726fa94102ade1399462ff698e268b21e447a2 (plain) (tree)


























                                                           
#!/usr/bin/env python


class Solution:
    def climbStairs(self, n: int) -> int:
        memo = {}

        def fact(n, memo):
            if n <= 1:
                return 1
            if n in memo:
                return memo[n]
            memo[n] = fact(n - 1, memo) + fact(n - 2, memo)
            return memo[n]

        return fact(n, memo)


def main():
    solution = Solution()
    print(solution.climbStairs(2))
    print(solution.climbStairs(3))
    print(solution.climbStairs(44))


if __name__ == "__main__":
    main()