SIMPLE JAVA APPROACH WITH EXPLANATION
\t// time complexity O(N) , space complexity O(height)\n\t/  approach :\n\t\t\t--> as we are given the starting red color node(x), the only place to start color
\t// time complexity O(N) , space complexity O(height)\n\t/*  approach :\n\t\t\t--> as we are given the starting red color node(x), the only place to start coloring blue that ensures blue to win is to color any adjacent node of x to blue.\n\t\t\t--> if we color left child of x to blue then we can stop the red color player to color any node of subtree starting from the left child of x.\n\t\t\t--> similar goes for  right child for x.\n\t\t\t--> if we initially color parent node of x to blue , then we can stop the red color player to color upper nodes of x and their remaining children.\n\t\t\t--> in either case blue player will be coloring only 1 part(left subtree/right subtree/ parent tree) and rest 2 parts are colored by red.\n\t\t\t--> find # nodes in any 1 part > # of nodes in remaining 2 parts , if yes then blue can win else cann\'t.\n\t*/\n\tclass Solution {\n\t\tpublic boolean btreeGameWinningMove(TreeNode root, int n, int x) {\n\t\t\tTreeNode redColor = findRedColor(root,x);\n\t\t\tint leftSubtree = count(redColor.left,null);\n\t\t\tint rightSubtree = count(redColor.right,null);\n\t\t\tint parentTree = count(root,redColor);\n\t\t\tif(leftSubtree> rightSubtree + parentTree)return true;\n\t\t\tif(rightSubtree> leftSubtree + parentTree)return true;\n\t\t\tif(parentTree> rightSubtree + leftSubtree)return true;\n\t\t\treturn false;\n\t\t}\n\n\t\tprivate TreeNode findRedColor(TreeNode root,int x){\n\t\t\tif(root==null)return null;\n\t\t\tif(root.val==x)return root;\n\t\t\tTreeNode l = findRedColor(root.left,x);\n\t\t\tif(l!=null)return l;\n\t\t\treturn findRedColor(root.right,x);\n\t\t}\n\t\tprivate int count(TreeNode root, TreeNode redColor){\n\t\t\tif(root==null || root==redColor)return 0;\n\t\t\treturn 1 + count(root.left,redColor) + count(root.right,redColor);\n\t\t}\n\t}
[]