Given step costs and a maximum jump size k, return the minimum cost required to reach the top. You may jump from 1 to k steps at a time. Pattern focus: Min cost climbing. This generalizes the classic staircase DP to a wider jump window.
cost = cost of each step, k = maximum jump length
minimum total cost to reach the top
Example 1:
Input:
cost = [1,2,3,4] k = 2
Output:
4
Explanation:
The cheapest path uses jumps that avoid the larger costs.
Example 2:
Input:
cost = [5,1,2,10,1] k = 3
Output:
2
Explanation:
Starting from the cheaper middle step leads to the best total.