C++| Java | 100% Faster | 0 ms | Easy Solution
C++\n### \n\nExplanation:\n\nThe node with value x divides the tree in three parts, parent region, left child region and right child region. If number of nodes 
### **C++**\n### \n\n**Explanation:**\n\nThe node with value x divides the tree in three parts, parent region, left child region and right child region. If number of nodes in any of those regions is more that n/2 then y can win.\n\n```\nclass Solution {\n    //This node will store the node with value X\n    TreeNode* X = NULL;\n    //This function will assign the node with value x to X.\n    void findX(TreeNode* root, int x){\n        if(!root||X) return;\n        if(root->val==x) X=root;\n        findX(root->left,x);\n        findX(root->right,x);\n    }\n    \n\t//This function will return the child count\n    int child_count(TreeNode* root){\n        if(!root) return 0;\n        return child_count(root->left)+child_count(root->right)+1;\n    }\n    \npublic:\n    bool btreeGameWinningMove(TreeNode* root, int n, int x) {\n        findX(root,x);\n        int lc = child_count(X->left);\n        int rc = child_count(X->right);\n\t\t//Get max from all three regions and return true if its greater than n/2\n        return max(max(lc,rc),n-lc-rc-1)>n/2;\n    }\n};\n\n```\n\n\n\n### **Java**\n### \n```\nclass Solution {\n    public boolean btreeGameWinningMove(TreeNode root, int n, int x) {\n        find(root,x);\n        int lc = count(p1.left);\n        int rc = count(p1.right);\n        return Math.max(Math.max(lc,rc),n-lc-rc-1)>n/2;\n    }\n    \n    TreeNode p1 = null;\n    \n    public void find(TreeNode root,int x){\n        if(root == null || p1!=null) return;\n        if(root.val == x) p1 = root;\n        find(root.left, x);\n        find(root.right,x);\n    }\n    \n    public int count(TreeNode root){\n        if(root == null) return 0;\n        return count(root.left)+count(root.right)+1;\n    }\n}\n\n```
['C', 'Java']