Skip to content

Instantly share code, notes, and snippets.

@hongtaoh
Created October 9, 2024 16:10
Show Gist options
  • Save hongtaoh/37b3269e5155f00eddeda53619795f4d to your computer and use it in GitHub Desktop.
Save hongtaoh/37b3269e5155f00eddeda53619795f4d to your computer and use it in GitHub Desktop.
Solution to Leetcode 70 Climbing Stairs
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