From 3bbe283cd774d3b976836b16cd17ca9208b4dbd9 Mon Sep 17 00:00:00 2001
From: bt3gl <138340846+bt3gl-google@users.noreply.github.com>
Date: Sun, 30 Jul 2023 12:38:49 -0700
Subject: [PATCH] Update climbing_stairs.py
---
math_logic_dp/climbing_stairs.py | 2688 +-----------------------------
1 file changed, 43 insertions(+), 2645 deletions(-)
diff --git a/math_logic_dp/climbing_stairs.py b/math_logic_dp/climbing_stairs.py
index 0b3f0b8..6a8a76c 100644
--- a/math_logic_dp/climbing_stairs.py
+++ b/math_logic_dp/climbing_stairs.py
@@ -1,2658 +1,56 @@
+'''
+You are climbing a staircase. It takes n steps to reach the top.
+Each time you can either climb 1 or 2 steps.
+In how many distinct ways can you climb to the top?
+'''
+
+
+def climb_stairs_o2n(n: int) -> int:
+ if n == 0 or n == 1:
+ return 1
+ return climb_stairs_o2n(n-1) + climb_stairs_o2n(n-2)
+def helper(n: int, memo: dict[int, int]) -> int:
+ if n == 0 or n == 1:
+ return 1
+ if n not in memo:
+ memo[n] = helper(n-1, memo) + helper(n-2, memo)
+ return memo[n]
-
-
-
-
-
-
-
- You signed in with another tab or window. Reload to refresh your session.
- You signed out in another tab or window. Reload to refresh your session.
- You switched accounts on another tab or window. Reload to refresh your session.
-
-
-
-
-