problem
题意:
solution1:动态规划;
class Solution { public: int minCostClimbingStairs(vector<int>& cost) { int n = cost.size(); vector<int> dp(n, 0); dp[0] = cost[0], dp[1] = cost[1]; for(int i=2; i<n; ++i)//errr.. { dp[i] = cost[i] + min(dp[i-1], dp[i-2]); } return min(dp[n-1], dp[n-2]); } };
参考
1. Leetcode_easy_746. Min Cost Climbing Stairs;
2. Grandyang;
完