Trains the technique from
LeetCode 1846Maximum Element After Decreasing and RearrangingThis 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 mason has one block per entry of blocks, and blocks[i] is how many courses of brick block i currently stands. Before building, the mason may apply either operation as often as wanted, in any order:
1 and never taller than it already is;The finished wall, read left to right, must satisfy both rules:
1 course;1 course.Every block must be used. Return the largest number of courses any block can stand in a finished wall.
Example 1
Shaving the two blocks of three courses down and ordering the wall as 1, 1, 2, 2, 3 obeys both rules, and its tallest block stands 3 courses.
Example 2
Ordering the wall as 1, 1, 2 after shaving the tall block from 5 courses to 2 obeys both rules, and its tallest block stands 2 courses.
Example 3
Shaving the two tall blocks to 2 and 3 courses and ordering the wall as 1, 2, 3 obeys both rules, and its tallest block stands 3 courses.
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_after_shaving(blocks: list[int]) -> int:public int tallestAfterShaving(int[] blocks)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.