Trains the technique from
LeetCode 987Vertical Order Traversal of a Binary TreeThis 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 studio suspends a mobile from one hook. Every piece of the mobile carries a weight and dangles at most two further pieces beneath it, one on a left arm and one on a right arm. An arm carries its piece one notch sideways and one notch further down: a left arm one notch to the left, a right arm one notch to the right. The piece on the hook occupies notch 0 at the top level.
The sculpture reaches you as pieces, a listing that walks the mobile one level at a time from the hook downward and, within a level, from left to right. Slot 0 holds the piece on the hook. Each piece that appears in the listing claims the next two free slots, its left arm first and its right arm second. A slot holding null carries no piece and claims no slots of its own; null slots at the very end of the listing may be dropped.
A photographer wants the mobile written out notch by notch. Produce one group per occupied notch, and place the groups from the leftmost notch to the rightmost. Inside a group, write the weights from the highest piece down to the lowest. Should two pieces of one group hang at the same level, write the lighter weight ahead of the heavier one.
Example 1
Notch -1 holds only the piece weighing 5. Notch 0 holds the hook piece 12 at the top level and 33 two levels down. Notches 1 and 2 hold 40 and 9.
Example 2
Notch 0 collects the hook piece 4 and, two levels down, both 6 and 1. Those two hang at the same level in the same notch, so the lighter 1 is written ahead of 6.
Example 3
A single piece hangs on the hook, so one notch is occupied and it holds one weight.
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 mobile_column_readout(pieces: list[int | None]) -> list[list[int]]:public List<List<Integer>> mobileColumnReadout(Integer[] pieces)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.