Sponsored
Use these hints if you're stuck. Try solving on your own first.
The best move y must be immediately adjacent to x, since it locks out that subtree.
Can you count each of (up to) 3 different subtrees neighboring x?
Solve with full IDE support and test cases