Simple Cpp solution passes all test cases
When the first player choses a node there are three options available for the second player.\nHe can either choose the parent or left child or right child. By d
When the first player choses a node there are three options available for the second player.\nHe can either choose the parent or left child or right child. By doing so he is blocking the chosen path for the first player as in a tree there is only one path between two nodes.\nSo what we can do is to chose the node out of three say lv(left child), rv (right child), or par(parent) and calculate the no. of nodes in that subtree. In doing so we only need lv and rv as par can be calculated using par =n - lv - rv - 1.\nNow we will choose the max among the three value if our max comes out to be greater than n/2\nthen it is possible for us to win the game.\n\nint count(TreeNode* root) {\n        if(!root)\n            return 0;\n        return count(root->left) + count(root->right) + 1;\n    }\n    \n    TreeNode* find(TreeNode* root, int x) {\n        if(!root)\n            return NULL;\n        if(root->val == x)\n            return root;\n        TreeNode* lv = find(root->left, x);\n        TreeNode* rv = find(root->right, x);\n        return lv ? lv : rv;\n    }\n    \n    bool btreeGameWinningMove(TreeNode* root, int n, int x) {\n        if(n == 1)\n            return false;\n        TreeNode* temp = find(root, x);\n        int lv = count(temp->left);\n        int rv = count(temp->right);\n        int par = n - lv - rv - 1;\n        int mx = max(lv, max(rv, par));\n        cout << lv << " " << rv << " " << par << " mx";\n        if(mx > n-mx)\n            return true;\n        return false;\n    }
[]