You are climbing a staircase with
n + 1steps, numbered from 0 ton.You are also given a 1-indexed integer array
costsof lengthn, wherecosts[i]is the cost of stepi.From step
i, you can jump only to stepi + 1,i + 2, ori + 3. The cost of jumping from stepito stepjis defined as:costs[j] + (j - i)2You start from step 0 with
cost = 0.Return the minimum total cost to reach step
n.
1 | class Solution { |