Trains the technique from
LeetCode 199Binary Tree Right Side ViewThis 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 broadcast network is wired as a binary tree of relays. Every relay may feed a left downstream relay and a right downstream relay, and relays at the same distance from the source form one tier. On each tier, the relay drawn furthest to the right is the one that reports that tier's health, so operations needs the reporting relay of every tier, from the source tier downward.
The tree arrives as network, a level-order listing: network[0] is the source relay's value, and the remaining entries give, tier by tier and left to right, the left feed then the right feed of each relay already listed. A null entry means that feed is absent; an absent feed contributes no entries of its own, and trailing null entries are omitted. An empty list means the network has no relays.
Return the values of the reporting relays, ordered from the source tier down to the deepest tier. Return an empty list when the network is empty. Note that a tier's rightmost relay need not descend from the previous tier's rightmost relay.
Example 1
The source reports its own tier. On the middle tier the right feed 11 sits furthest right, and on the bottom tier only 6 and 14 exist, so 14 reports.
Example 2
The source has no left feed, so tier two holds only 4, whose two feeds 9 and 2 form tier three and 2 reports it.
Example 3
Relay 21 has no left feed, so tier three is -2, 30 and the deepest tier is fed from the left branch alone, which makes 11 that tier's reporter.
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 tier_edge_relays(network: list) -> list[int]:public List<Integer> tierEdgeRelays(Integer[] network)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.