Skip to content

Instantly share code, notes, and snippets.

@Desolve
Created July 5, 2019 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Desolve/e6ca8d674da9778e3a36362e4c6ec032 to your computer and use it in GitHub Desktop.
Save Desolve/e6ca8d674da9778e3a36362e4c6ec032 to your computer and use it in GitHub Desktop.
0070 Climbing Stairs
class Solution {
public int climbStairs(int n) {
if(n <= 2) return n;
int[] res = new int[n];
res[1-1] = 1;
res[2-1] = 2;
for(int i = 3; i <= n; i++) {
res[i-1] = res[i-1-1] + res[i-2-1];
}
return res[n-1];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment