70. Climbing Stairs (DP)

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

 

posted @ 2018-08-01 01:38  jasoncool1  阅读(120)  评论(0编辑  收藏  举报