Created
October 9, 2024 16:10
-
-
Save hongtaoh/37b3269e5155f00eddeda53619795f4d to your computer and use it in GitHub Desktop.
Solution to Leetcode 70 Climbing Stairs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
# dynamic programming | |
def climbStairs(self, n: int) -> int: | |
one, two = 1, 1 | |
for _ in range(n-1): | |
temp = one | |
one += two | |
two = temp | |
return one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment