C++ Recursion Solution
Runtime: 4 ms, faster than 82.92% of C++ online submissions for Binary Tree Coloring Game.\nMemory Usage: 11.6 MB, less than 5.05% of C++ online submissions for
Runtime: 4 ms, faster than 82.92% of C++ online submissions for Binary Tree Coloring Game.\nMemory Usage: 11.6 MB, less than 5.05% of C++ online submissions for Binary Tree Coloring Game.\n\nPlayer 1 chooses Node x first which has 3 neighbor nodes (parent, left, right). \nPlayer 2 will choose one of those 3 neighbor nodes at first which has maximum childs in its subtree and all\nthe nodes of that subtree  will be the count of Player 2. \nIf max node count of Player 2 is greater than n/2 then he WIN, otherwise he LOSE. \n\n```\nclass Solution {\npublic:\n    \n    // find neighbor nodes of node x\n    void findNodes(TreeNode *root, int x, vector<TreeNode*>&neighbors)\n    {\n        if(!root) return;\n        \n        // found target node x\n        if(root->val==x)\n        {\n            neighbors.push_back(root->left);\n            neighbors.push_back(root->right);\n            \n            return;\n        }\n        \n        findNodes(root->left,x,neighbors);\n        findNodes(root->right,x,neighbors);        \n    }\n    \n    // count nodes of the subtree\n    int countNodes(TreeNode *root)\n    {\n        if(!root) return 0;\n        \n        return countNodes(root->left) + countNodes(root->right) + 1;\n    }\n    \n    bool btreeGameWinningMove(TreeNode* root, int n, int x) {\n        \n        // store neighbor node of node x\n        vector<TreeNode*>neighbors;\n        \n        // find neighbor nodes\n        findNodes(root,x,neighbors);\n        \n        // count left child neighbor subtree nodes\n        int leftSubtreeCount = countNodes(neighbors[0]);\n        \n        // count right child neighbor subtree nodes        \n        int rightSubtreeCount = countNodes(neighbors[1]);\n        \n        // count parent neighbor subtree nodes\n        int parentSubtreeCount = n - 1 - leftSubtreeCount - rightSubtreeCount;\n        \n        // return true if max node count of player 2 is greater than n/2 which player 2 can choose to WIN\n        // otherwise return false means player 2 lose\n        return max({leftSubtreeCount,rightSubtreeCount,parentSubtreeCount}) > n/2;\n    }\n};\n```
['Depth-First Search', 'Recursion', 'C']