Java Simple Code 100% time and 100% memory with explanation.
Suppose the first player marked node x. The main concept is, being a second player, we can stop the first player from expanding by either marking the parent of 
Suppose the first player marked node ***x***. The main concept is, being a second player, we can stop the first player from expanding by either marking the parent of ***x***, right child of ***x*** or the left child of ***x***. So, let\'s count the number of nodes in the left subtree of the node ***x*** as ***cl*** and count the number of nodes in the right subtree of the node ***x*** as ***cr***. Subtracting this from the total number of nodes and reducing the result by 1, we can get the number of nodes present in the tree but not in the subtree of which ***x*** is the root, as ***z***. The variables ***z***, ***cl*** and ***cr*** stores the number of nodes we can get if we mark the parent, left child or right child of ***x*** respectively. We can win if either one of the variables is greater than the sum of the other two added with 1. 1 is added to exclude the temp node itself.\n```\nclass Solution {\n    int cl,cr;\n    TreeNode temp;\n    public boolean btreeGameWinningMove(TreeNode root, int n, int x) {\n        cl=0;\n        cr=0;\n        temp=null;\n        if(root==null)\n            return false;   // we cannot win if there is no tree.\n        search(root,x); // to search the node with value x in the tree.\n        if(temp==null)\n            return true; // if the node is not present we will always win marking the root of the original tree.\n        dfs(temp.left,true);// to count nodes in left subtree.\n        dfs(temp.right,false);// to count nodes in right subtree.\n        int z=n-cl-cr-1;// to count nodes present in original tree but not in the subtree of which node(temp) with value x is the root.\n        return (z>cl+cr+1)||(cl>z+cr+1)||(cr>z+cl+1);        // if either one of the variables is greater than the sum of the other two added with 1. \n\t\t// 1 is added to exclude the temp node itself.\n    }\n    public void dfs(TreeNode root,boolean f){\n\t// f is true for left subtree and false for right subtree.\n        if(root==null)\n            return;\n        if(f)\n            cl++;\n        else\n            cr++;\n        dfs(root.left,f);\n        dfs(root.right,f);\n    }\n    public void search(TreeNode root,int x){\n\t// for searching the node with value x by dfs.\n        if(root==null)\n            return;\n        if(temp!=null)\n            return;\n        if(root.val==x){\n            temp=root;\n            return;\n        }\n        search(root.left,x);\n        search(root.right,x);            \n    }\n}\n```
[]