Trains the technique from
LeetCode 1609Even Odd 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 tower hangs from a single top tile. Every tile holds at most two tiles below it in a first and a second slot, and either slot may be empty. Each tile shows a number.
A flat list is read level by level: its first entry is the top tile's number, and reading left to right, every entry that is not null claims the next two unused positions as its first and second slot in that order, while null marks an empty slot and claims no positions of its own.
Number the rows of tiles from 0 at the top. The tower is tidy when both of the following hold:
Return true when the tower is tidy.
Example 1
Row 0 holds the odd number 1. Row 1 holds 4 then 2, both even and falling, so the tower is tidy.
Example 2
Row 1 holds 2 then 4. Both are even, but an odd-numbered row has to fall from left to right.
Example 3
Row 0 holds 1, row 1 holds 4 then 2, and row 2 holds 3, 5, 7 and 9. The even rows rise through odd numbers and the odd row falls through even ones.
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 is_even_odd_tree(tower: list) -> bool:public boolean isEvenOddTree(Integer[] tower)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.