Guest User

Untitled

a guest
Jan 11th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. class Solution {
  2. public:
  3. int minCostClimbingStairs(vector<int>& cost) {
  4. int step1 = cost[0], step2 = cost[1];
  5. for(int i = 2; i < cost.size(); i++) {
  6. int res = min(step1, step2) + cost[i];
  7. step1 = step2;
  8. step2 = res;
  9. }
  10. return min(step1, step2);
  11. }
  12. };
Add Comment
Please, Sign In to add comment