Staircase Token Hopper
Problem Description
You are climbing a staircase with `n` steps. Each step has a token cost stored in `stepCost`, where `stepCost[i]` is the cost to step onto the `i`-th stair (0-indexed). Once you pay the cost of a step, you may jump either 1 or 2 steps forward.
You may start from either step 0 or step 1. Return the minimum total cost to reach the top (one step beyond the last index).
**Example 1:**
```
Input: stepCost = [3, 2, 4, 1]
Output: 3
Explanation: Start at index 1 (cost 2), jump to index 3 (cost 1). Total = 3.
```
**Example 2:**
```
Input: stepCost = [5, 1, 2, 8, 3]
Output: 6
Explanation: Start at index 1 (cost 1), jump to index 2 (cost 2), jump to index 4 (cost 3). Total = 6.
```
Constraints
- 2 <= stepCost.length <= 1000
- 0 <= stepCost[i] <= 999
Follow-up
Can you generalise so that from any step you may jump up to k steps forward?
Hints
Try the problem first. If you get stuck, you can reveal hints one at a time.
Solution
Leaderboard
No entries yet for python.
Be the first — submit an accepted solution.