class Solution {public: int minCostClimbingStairs(vector& cost) { //dp[i]表示爬到第i阶楼梯需要的最小花费 vector dp(cost.size() + 1, 0); for(int i = 2; i //每次选取最小的方案 dp[i] = min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]); return dp[cost.size()]; }};