Quant Memo
Coding/●●●●

Fewest hops to reach settlement

You are at stage 0 of a settlement pipeline. From stage i you may advance forward by any amount from 1 up to steps[i] stages. Reach the last stage using the fewest hops. Assume the last stage is always reachable.

steps = [2, 3, 1, 1, 4]
-> 2        # stage 0 -> stage 1 (hop of 1), then stage 1 -> stage 4 (hop of 3)

Return the minimum number of hops to reach the last stage in O(n) time.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions