Hi, this is Shunchi!

  • Home

  • Tags0

  • Archives267

  • Categories0

  • Curricula

  • DSA

  • LeetCode_Notes

  • Interviews

  • General

  • Resume

70. Climbing Stairs

Posted on 2021-01-04 | Edited on 2021-01-22

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];
}
}

<1…8910…267>
ShunchiZhou

ShunchiZhou

267 posts
RSS
GitHub E-Mail Gitbook Linkedin
© 2024 ShunchiZhou
Powered by Hexo v5.4.0
|
0%