2066. Add Minimum Number of Rungs
My accepted Python solution to LeetCode problem 2066, Add Minimum Number of Rungs, running in 8ms.
- Difficulty: Medium
- Python
- Runtime 8ms
- Memory 30.6MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 8ms, memory 30.6MB, accepted 2025-12-29.
class Solution:
def addRungs(self, rungs: List[int], dist: int) -> int:
count = 0
prev = 0
for rung in rungs:
gap = rung - prev
if gap > dist:
count += (gap - 1) // dist
prev = rung
return count