Trains the technique from
LeetCode 94Binary Tree Inorder TraversalThis 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 test rig pushes fluid through a branching manifold. Every valve carries a stamped tag and has two outlets, a near tap and a far tap, each of which either feeds another valve or is capped.
The manifold reaches you flattened into the list manifold, written one rank at a time from the top valve downward and left to right inside a rank. Each valve that appears claims the next two entries of the list as its near tap and its far tap, in that order, where null marks a capped tap. A capped tap claims no entries of its own. Trailing entries that would record nothing but caps are left off, and an empty list means the rig holds no valves.
A technician always reads the rig in the same order: everything fed by a valve's near tap, then that valve's own tag, then everything fed by its far tap. Return the tags in the order the technician reads them. Tags may repeat, and a rig with no valves reads as an empty list.
Example 1
Valve 9 feeds -7 on its near tap and 4 on its far tap, so that whole branch reads -7, 9, 4 before the top valve 2. Valve 1 has a capped near tap, so it is read before -3.
Example 2
Each valve only feeds a near tap, so the deepest valve is read first and the top valve last.
Example 3
Repeated tags are reported once per valve, so the readout keeps all three.
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 valve_readout(manifold: list) -> list[int]:public List<Integer> valveReadout(Integer[] manifold)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.