70. Climbing Stairs

LeetCode

1
2
3
4
5
6
7
8
9
10
11
12
class Solution {
public int climbStairs(int n) {
if(n==1) return 1;
int[] memo=new int[n+1];
memo[1]=1;
memo[2]=2;
for(int i=3;i<=n;i++){
memo[i]=memo[i-1]+memo[i-2];
}
return memo[n];
}
}

0%