0 there is no tree at all;
- at stage 1 it is a single node;
- at stage s ≥ 2 it is a root whose left subtree is the stage s - 2 tree and whose right subtree is the stage s - 1 tree.
Two gardeners play on the tree of stage stage, taking turns. On a turn, a gardener picks any remaining node and cuts it off together with everything growing below it. Whoever has to cut the root loses.
Return True if the player who moves first wins when both play optimally, and False otherwise.stage=3 → True
The first player cuts the leaf below the root's right child. Exactly two leaves remain: the second player cuts one, the first cuts the other, and the second is left with only the root.
stage=1 → False
The tree is a lone root, so the first player has to cut it right away.
stage=7 → False
stage=3
True
Run checks the first 3 tests in your browser. Submit checks all 103 tests on the server, hidden ones included.