Given step costs and a list of broken steps that cannot be used, return the minimum cost to reach the top using 1 or 2 step jumps. Pattern focus: Min cost climbing. This adds blocked states and forces you to skip invalid transitions.
cost = cost of each step, broken = forbidden step indices
minimum total cost to reach the top, or -1 if impossible
Example 1:
Input:
cost = [1,100,1,1] broken = [1]
Output:
2
Explanation:
The cheapest valid route avoids the broken step 1.
Example 2:
Input:
cost = [5,1,2,10,1] broken = [2]
Output:
11
Explanation:
The best valid route passes through the cheaper reachable steps.