Advertisement
nikunjsoni

746

Jun 7th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int minCostClimbingStairs(vector<int>& cost) {
  4.         cost.push_back(0);
  5.         for(int i=2; i<cost.size(); i++)
  6.             cost[i] += min(cost[i-1], cost[i-2]);
  7.         return cost.back();
  8.     }
  9. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement