[C++] beats 100% in time and memory [Detailed Explanantion]
\n/*\n    https://leetcode.com/problems/binary-tree-coloring-game/\n    \n    Idea is to find the total nodes in the left, right and before node x. Then the sec
```\n/*\n    https://leetcode.com/problems/binary-tree-coloring-game/\n    \n    Idea is to find the total nodes in the left, right and before node x. Then the second player can just\n    choose to color the branch with majority nodes(> N/2). If such a node is there then he can win, otherwise not possible.\n    \n    TC: O(n)\n    \n*/\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n */\nclass Solution {\npublic:\n    \n    int postTraversal(TreeNode* root, int& x, bool& can_win, int n) {\n        if(!root)\n            return 0;\n        \n        int left = postTraversal(root->left, x, can_win, n);\n        int right = postTraversal(root->right, x, can_win, n);\n        \n        // if the current node is the one chosen by first player\n        if(root->val == x) {\n            // In order for the second player to win, he needs to select a neighouring branch\n            // which has more nodes than the combined nodes of other two neighbouring branches\n            // +1 for including the current node\n            int num_nodes_before = n - (1 + left + right);\n            can_win = (num_nodes_before > left + right) || \n                        (left > num_nodes_before + right) ||\n                        (right > num_nodes_before + left);\n        }\n        \n        // total no. of nodes int the subtree with the current node as root \n        return left + right + 1;\n    }\n    \n    bool btreeGameWinningMove(TreeNode* root, int n, int x) {\n        // whether second player can win or not\n        bool can_win = false;\n        postTraversal(root, x, can_win, n);\n        return can_win;\n    }\n};\n```
[]