← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are climbing a staircase that has n steps. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Key Insight: This is the Fibonacci sequence! ways(n) = ways(n-1) + ways(n-2).
Related: Climbing Stairs with K Steps - Generalized version where you can climb 1 to k steps