From 0b060298650dca42558c6540c80961bfcf5e7812 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Wed, 17 Jan 2024 21:53:36 -0500 Subject: 70 --- 70/main.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 70/main.py diff --git a/70/main.py b/70/main.py new file mode 100755 index 0000000..d0726fa --- /dev/null +++ b/70/main.py @@ -0,0 +1,27 @@ +#!/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() -- cgit v1.2.3