Trains the technique from
LeetCode 1840Maximum Building HeightThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A grain yard has silos silos standing in a straight row, numbered 1 through silos. Each silo is built up from identical rings, so its size is a whole number of rings, never negative. Silo 1 is the loading silo and holds exactly 0 rings.
A shared walkway runs along the row, and it can only span one ring of difference, so two silos standing next to each other differ by at most one ring.
Some silos sit under overhead cables. Each entry caps[i] = [pos, limit] says silo pos may hold at most limit rings. Every listed pos is different, and a silo with no entry has no limit of its own beyond the walkway rule.
The yard wants one silo as tall as the rules allow. Return the largest number of rings a single silo can hold in any arrangement that obeys every rule above.
Example 1
The row 0, 1, 2, 3, 3, 2 obeys every rule: silo 1 holds 0 rings, neighbours never differ by more than one ring, and silo 6 stays within its limit of 2. Its tallest silo holds 3 rings.
Example 2
The row 0, 1, 2, 3, 4, 3, 2, 2, 1, 0 keeps silo 5 under its limit of 8 and silo 10 at its limit of 0, and its tallest silo holds 4 rings.
Example 3
With no cables the row 0, 1, 2, 3, 4 is allowed, and its tallest silo holds 4 rings.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def tallest_silo(silos: int, caps: list[list[int]]) -> int:public int tallestSilo(int silos, int[][] caps)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.