Trains the technique from
LeetCode 554Brick WallThis 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.
An office partition is described by wall, listed from the top row downwards. Row i is the list of panel widths in that row, read from the left edge to the right edge, and every row spans the same total width.
A cable is dropped straight down the partition, from the top of the top row to the bottom of the bottom row, at one position strictly inside the partition: the two outer edges are not allowed. In each row the cable either slips down the seam where two neighbouring panels meet, touching neither of them, or it passes through the body of one panel. Return the smallest number of panels a single cable can pass through.
Example 1
Every row is 8 wide. A cable dropped 2 from the left edge slips down the seam of row 1 and the seam of row 2, and passes through a panel in row 0 and in row 3, giving 2 panels.
Example 2
Every row is 3 wide. A cable dropped 1 from the left edge slips down a seam in row 0 and a seam in row 2, and passes through the single panel of row 1, giving 1 panel.
Example 3
Each row holds one panel 6 wide and has no seam, and the cable is not allowed on either outer edge, so it passes through a panel in all 3 rows.
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 least_bricks(wall: list[list[int]]) -> int:public int leastBricks(List<List<Integer>> wall)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.