Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int minCostClimbingStairs(vector<int>& cost) {
- int step1 = cost[0], step2 = cost[1];
- for(int i = 2; i < cost.size(); i++) {
- int res = min(step1, step2) + cost[i];
- step1 = step2;
- step2 = res;
- }
- return min(step1, step2);
- }
- };
Add Comment
Please, Sign In to add comment