minimumCost
with a length of cost.length + 1
, and set the first two elements to 0 (base cases).i
, calculate minimumCost[i]
using the recurrence relation: minimumCost[i] = min(minimumCost[i - 1] + cost[i - 1], minimumCost[i - 2] + cost[i - 2])
.minimumCost
, which represents the minimum cost to reach the top of the floor.