My Vault

Home

❯

leetcode

❯

climbing stairs

climbing-stairs

Jul 25, 20241 min read

  • cse/algorithm
  • leetcode
  • blind75

Climbing Stairs

https://leetcode.com/problems/climbing-stairs/

A simple dp example.

if n == 1:
    return 1
table = [0] * (n + 1)
table[1] = 1
table[2] = 2
for i in range(3, n + 1):
    table[i] = table[i - 1] + table[i - 2]
return table[n]

Graph View

Created with Quartz v4.5.2 © 2026

  • GitHub
  • Homepage