aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-01-18 02:53:36 +0000
committerterminaldweller <devi@terminaldweller.com>2024-01-18 02:53:36 +0000
commit0b060298650dca42558c6540c80961bfcf5e7812 (patch)
treed4da3825b56af0a0840ef01eb08473b074d075f9
parent1207 (diff)
downloadleetcode-0b060298650dca42558c6540c80961bfcf5e7812.tar.gz
leetcode-0b060298650dca42558c6540c80961bfcf5e7812.zip
70
Diffstat (limited to '')
-rwxr-xr-x70/main.py27
1 files changed, 27 insertions, 0 deletions
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()