rungs, and you need to reach the top one.
In one move you can climb to the next rung only if it is at most reach above where you are now (the floor or a rung). You may nail a new rung at any positive integer height that does not already have one.
Return the smallest number of rungs you have to add to get to the top.rungs=[2, 4, 11], reach=3 → 2
The floor to 2 and 2 to 4 are within reach. Between 4 and 11 the gap is 7, so two new rungs are needed, say at 7 and 10.
rungs=[5, 6, 7], reach=1 → 4
Each climb covers exactly one unit, so rungs at 1, 2, 3 and 4 are missing below the first one at height 5.
rungs=[4, 8, 12], reach=4 → 0
Every gap is exactly 4, so nothing needs to be added.
rungs is strictly increasingrungs=[2, 4, 11], reach=3
2
Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.