Loading problem…
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?
n
climbStairs(2); // 2 // Ways: 1 step + 1 step, or 2 steps climbStairs(3); // 3 // Ways: 1+1+1, 1+2, 2+1 climbStairs(4); // 5 // Ways: 1+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2
3 hints available with Pro