mirror of
https://github.com/20kaushik02/leetcode-gulag.git
synced 2025-12-06 08:24:07 +00:00
17 lines
323 B
C++
17 lines
323 B
C++
#include "soln.hpp"
|
|
|
|
int Solution::minCostClimbingStairs(vector<int> &cost)
|
|
{
|
|
int n = cost.size();
|
|
for (int i = 2; i < n; i++)
|
|
{
|
|
cost[i] += min(cost[i - 1], cost[i - 2]);
|
|
}
|
|
return min(cost[n - 1], cost[n - 2]);
|
|
}
|
|
|
|
bool Solution::test(vector<int> &cost, int answer)
|
|
{
|
|
return minCostClimbingStairs(cost) == answer;
|
|
}
|