Trains the technique from
LeetCode 84Largest Rectangle in HistogramThis 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 quarry face is stored as columns, where columns[i] is how many square slate tiles are stacked in the i-th column. Every column is one tile wide, columns touch with no gap, and all of them rest on the same floor. A column may hold no tiles at all.
A cutter can lift out one rectangular slab. The slab has to span a run of neighbouring columns and sit flush on the floor, so its height can never exceed the shortest column it spans, and its width is the number of columns in the run.
Report the tile count of the biggest slab the cutter can lift, that is the largest value of run width times the smallest column height inside the run. If no column holds a tile, the answer is 0.
Example 1
Spanning the last four columns caps the height at 4 tiles, giving 4 by 4. Nothing else reaches 16: the single tallest column only yields 8, and taking all five columns caps the height at 3 for a total of 15.
Example 2
Both columns are the same height, so the slab covers the whole face without wasting any height.
Example 3
The face is bare, so every run has a shortest height of zero and no slab can be lifted.
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 largest_slate_cut(columns: list[int]) -> int:public int largestSlateCut(int[] columns)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.