Two players play a turn-based game on a binary tree. We are given the root of this binary tree, and the number of nodes n in the tree. n is odd, and each node has a distinct value from 1 to n.
Initially, the first player names a value x with 1 <= x <= n, and the second player names a value y with 1 <= y <= n and y != x. The first player colors the node with value x red, and the second player colors the node with value y blue.
Then, the players take turns starting with the first player. In each turn, that player chooses a node of their color and colors an uncolored neighbor (either the left child, right child, or parent). If a player cannot choose such a node, they must pass their turn. If both players pass, the game ends, and the winner is the player that colored more nodes.
You are the second player. If it is possible to choose such a y to ensure you win the game, return true. If it is not possible, return false.
Input & Output
Constraints
- 1 ≤ n ≤ 500
- n is odd
- 1 ≤ x ≤ n
- Tree has exactly n nodes with values 1 to n