题解 | #跳台阶#
跳台阶
https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
class Solution { public: int jumpFloor(int number) {//动态规划 // write code here vector<int> dp(number+1, 1); dp[1] = 1; dp[2] = 2; for(int i = 3; i <= number; ++i) { dp[i] = dp[i-2] + dp[i-1];// 直觉,当前可执行方法,是上步和上上步的操作结果 } return dp[number]; } };
挤挤刷刷! 文章被收录于专栏
记录coding过程