70. Climbing Stairs
public class Solution { public int climbStairs(int n) { if(n==1) return 1; if(n==2) return 2; int[] res=new int[n+1]; res[1]=1; res[2]=2; for(int i=3;i<=n;i++) { int temp=res[i-1]+res[i-2]; res[i]=temp; } return res[n]; } }
public class Solution { public int climbStairs(int n) { if(n==1) return 1; if(n==2) return 2; int[] res=new int[n+1]; res[1]=1; res[2]=2; for(int i=3;i<=n;i++) { int temp=res[i-1]+res[i-2]; res[i]=temp; } return res[n]; } }