blob: 3df886acfff60b4d909b5463115ff39b4669779b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include "leetcode.h"
class Solution {
public:
int minCostClimbingStairs(vector<int> &cost) {
for (int i = cost.size() - 3; ~i; i--)
cost[i] += min(cost[i + 1], cost[i + 2]);
return min(cost[0], cost[1]);
}
};
int main() {
Solution obj;
vector<int> cost = {10, 15, 20};
cout << obj.minCostClimbingStairs(cost);
}
|