Dynamic Programming pattern

Climbing Stairs

You are climbing a staircase that takes n steps to reach the top. Each time you can climb 1 or 2 steps. In how many distinct ways can you reach the top? Watch it run step by step, then write your own pseudocode and get it checked by AI.

  • LeetCode 70
  • Easy
  • 2 approaches

Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.

Dynamic ProgrammingLeetCode 70

Easy

From the first idea to the best one

  1. 01 Brute force · recursion O(2ⁿ)O(n) space
  2. 02 Optimized · tabulation O(n)O(n) space
Each approach plays step by step, with its time and space.

What you will learn

  • How to read Climbing Stairs and spot the dynamic programming pattern in it
  • Brute force · recursion: O(2ⁿ) time, O(n) space
  • Optimized · tabulation: O(n) time, O(n) space
  • The pseudocode for each approach, its line lit as the animation runs
  • Practice: write your own pseudocode and get it checked

More Dynamic Programming

See Climbing Stairs run, step by step

Sign in and this page opens on the animation, with all 18 Dynamic Programming problems beside it.

DSA comes with the all labs plan and every ChaiCode batch.