Reaching Far Along Buildings with Bricks and Ladders

Asked at Zip · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026

You stand on building `0` in a row of buildings and want to walk to the right, one building at a time. Moving from building `i` to building `i + 1` is free when the next building is not taller. When it is taller, you must cover the climb `heights[i + 1] - heights[i]` with either that many bricks or one ladder, and a ladder covers a climb of any height. You have a limited number of bricks and ladders. Find how far you can get, and report how each step was covered.

Loading the problem…