Tap here to switch tabs
Problem
Submissions

Problem: Add Minimum Number of Rungs

med
30 min
Try to solve the Add Minimum Number of Rungs problem.

Statement

You are given a strictly increasing integer array rungs representing the heights of rungs on a ladder, and an integer dist. You start at height 00 and can climb to the next rung if the difference in height between your current position and the rung is at most dist.

You may add rungs at any positive integer heights.

Return the minimum number of rungs you must add to reach the highest rung.

Constraints:

  • 1≤1 \leq rungs.length ≤105\leq 10^5

  • 1≤1 \leq rungs[i] ≤109\leq 10^9

  • 1≤1 \leq dist ≤109\leq 10^9

  • rungs is strictly increasing.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Add Minimum Number of Rungs

med
30 min
Try to solve the Add Minimum Number of Rungs problem.

Statement

You are given a strictly increasing integer array rungs representing the heights of rungs on a ladder, and an integer dist. You start at height 00 and can climb to the next rung if the difference in height between your current position and the rung is at most dist.

You may add rungs at any positive integer heights.

Return the minimum number of rungs you must add to reach the highest rung.

Constraints:

  • 1≤1 \leq rungs.length ≤105\leq 10^5

  • 1≤1 \leq rungs[i] ≤109\leq 10^9

  • 1≤1 \leq dist ≤109\leq 10^9

  • rungs is strictly increasing.