# LeetCode - 1936. Add Minimum Number of Rungs ### 題目網址:https://leetcode.com/problems/add-minimum-number-of-rungs/ ###### tags: `LeetCode` `Medium` `數學` ```cpp= /* -LeetCode format- Problem: 1936. Add Minimum Number of Rungs Difficulty: Medium by Inversionpeter */ static const auto Initialize = []{ ios::sync_with_stdio(false); cin.tie(nullptr); return nullptr; }(); class Solution { public: int addRungs(vector<int>& rungs, int dist) { int amount = 0, nowHeight = 0; for (int &i : rungs) { amount += (i - nowHeight - 1) / dist; nowHeight = i; } return amount; } }; ```