Given a staircase with a given number of stairs, num, write a function that returns the number of different ways one can climb this set of stairs. A person is able to climb the stairs either one at a time, or skip a step, or a mix of both.
climbStairs(2); // should return 2: one step at a time (1 + 1), or skip a step (2).
climbStairs(0); // should return 1
climbStairs(1); // should return 1
climbStairs(5); // should return 8
climbStairs(100); // should return 573147844013817200640
Feel free to diagram out yourself how you would go up these steps! There may be a pattern that you can take advantage of in your code. Ask yourself
- What does it mean to have only 0, 1, 2 steps?
- What happens when I have 3 steps? 4?
Once you come to a good solution:
- What happens on large input sizes like 15, or even 1000? Will this program timeout?