You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
题目链接:https://leetcode.com/problems/climbing-stairs/
题目分析:斐波那契数列
public class Solution {
public int climbStairs(int n) {
int[] fib = new int[n + 1];
fib[0] = 1;
fib[1] = 1;
for (int i = 2; i <= n; i ++) {
fib[i] = fib[i - 1] + fib[i - 2];
}
return fib[n];
}
}