70. Climbing Stairs#
1public int climbStairs(int n) {
2 if (n == 1) return 1;
3 if (n == 2) return 2;
4
5 int first = 1;
6 int second = 2;
7 int third = first + second;
8
9 for (int i = 3; i <= n; i++) {
10 third = first + second;
11
12 first = second;
13 second = third;
14 }
15
16 return third;
17}