Intern — Middle
Counting the number of ways to climb stairs
livecode
Task condition
You need to reach the top of a staircase containing n steps. You can climb either one or two steps at a time. Determine how many different sequences of steps can lead to the last step.
Example 1: Input: n = 2 Output: 2 Options: 1 step + 1 step, 2 steps
Example 2: Input: n = 3 Output: 3 Options: 1 + 1 + 1, 1 + 2, 2 + 1
class Solution {
public int climbStairs(int steps) {
// implementation
}
}