题解 | #跳台阶扩展问题#
跳台阶扩展问题
http://www.nowcoder.com/practice/22243d016f6b47f2a6928b4313c85387
动态规划
public class Solution {
public int jumpFloorII(int target) {
if(target <= 2){
return target;
}
int[] dp = new int[target+1];
dp[0] = 0;
for (int i = 1; i <= target; i++) {
int j = i - 1;
dp[i] = 1;
while (j >= 1){
dp[i] += dp[j];
j--;
}
}
return dp[target];
}
}
查看3道真题和解析