Notice Period

Toll Stairs

easy

A mountain footpath is fitted with toll gates — gate i charges toll[i] the moment you step on it. From any gate you can hop forward 1 or 2 gates.

You may begin at gate 0 or gate 1, and the trail ends just past the last gate. Return the minimum total toll to get past the end.

Example 1
in toll = [10, 15, 20]
out 15
Start at gate 1, pay 15, hop two gates past the end.
Example 2
in toll = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1]
out 6
Pay the six 1-tolls, leapfrogging every 100.
Constraints
  • · 2 <= len(toll) <= 1000
  • · 0 <= toll[i] <= 999
similar problem on LeetCode ↗
solution.pyloading python…
test results
Hit ▶ Run to test your code against the visible cases.