JAVA AC solution || 0ms
intuition that i got is if the player x already took his chance we have to greedily choose max of (left subtree of x,right subtree of x,other subtree)\nas we ch
intuition that i got is if the player x already took his chance we have to greedily choose max of (left subtree of x,right subtree of x,other subtree)\nas we choose this then if the other size is still greater than our choosed size we cant win\nelse we can win\n```\nclass Solution {\n    int xRightSubtreeSum=0;\n    int xLeftSubtreeSum=0;\n    public int size(TreeNode root,int x){\n        if(root==null)return 0;\n        \n        int leftSize=size(root.left,x);\n        int rightSize=size(root.right,x);\n        \n        if(root.val==x){\n            xRightSubtreeSum=rightSize;\n            xLeftSubtreeSum=leftSize;\n        }\n        return leftSize+rightSize+1;\n    }\n    public boolean btreeGameWinningMove(TreeNode root, int n, int x) {\n        size(root,x);\n        \n        int otherSubtreeSize=n-(xLeftSubtreeSum+xRightSubtreeSum+1);\n        \n        //we try to take max possible subtree\n        int yMax=Math.max(otherSubtreeSize,Math.max(xLeftSubtreeSum,xRightSubtreeSum));\n        \n        int rest=n-yMax;\n        \n        if(rest>yMax){//after taking max... the rest is still greater then we cant win\n            return false;\n        }\n        return true;\n    }\n}\n```
['Recursion', 'Game Theory', 'Java']