Created
July 5, 2019 08:51
-
-
Save Desolve/e6ca8d674da9778e3a36362e4c6ec032 to your computer and use it in GitHub Desktop.
0070 Climbing Stairs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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