✅ [C++] Easy Intuitive solution with Explanation
This question is easy once you figure out what to do. We need to check if we can win or not. Its simple. Just reduce the win chances of your opponent. \nHow do 
This question is easy once you figure out what to do. We need to check if we can win or not. **Its simple**. Just reduce the win chances of your opponent. \n***How do we do that?***\nWe will try to block the movement of the oppenent(Lets call him red) by choosing one of his neighbour. That way, he will have no choice and he will be forced to move in the only remaining two directions. Here, three directions are \n* toward his parent, \n* towards his left child, \n* towards his right child\n\nNow, to ensure our win, we will block the one having more number of nodes connected to it. To check the number of nodes, we maintain a child array. This child array will store the number of children of a node. So, if we color the parent of red node, we will have `child[root]-child[rednode]` nodes to color while red node will have `child[rednode]` nodes. \n**Why  `child[root]-child[rednode]`?**\nWell, every parent of a node is also its neighbour. So we can also move upwards, towards parent of each node. Thus, we have to count all those nodes as well. Therefore, we check directly for child[root], and since some of the nodes are already occupied by red node, thus we need to subtract those froom child[root]. Similiarly, we do for the left node and right node and check if we can win or not. \n\n```\nclass Solution {\npublic:\n    TreeNode* X;\n    bool btreeGameWinningMove(TreeNode* root, int n, int x) {\n        vector <int> child(n+1,0);\n        \n        dfs(root,0,x,child);\n        \n        if(child[root->val]>2*child[x]) return true;\n        if(X->left and 2*child[X->left->val]>child[root->val]) return true;\n        if(X->right and 2*child[X->right->val]>child[root->val]) return true;\n        return false;\n    }\nprotected:\n    int dfs(TreeNode* root, int parent, int x, vector<int>&child){\n        if(!root) return 0;\n        \n        // Since we would need to access left and right child too. We can also have two int variables for the same\n        if(root->val == x) X=root;\n        \n        int left = dfs(root->left,root->val,x,child);\n        int right = dfs(root->right,root->val,x,child);\n        \n        return child[root->val] = 1+left+right;\n    }\n};\n```
['Depth-First Search', 'C', 'C++']