Java 0ms - DFS
\n Describe your first thoughts on how to solve this problem. \n\n Descre your approach to solving the problem. \n\n# Complexity\n- Time complexity: O(n)\n Add 
\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- Descre your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() {}\n *     TreeNode(int val) { this.val = val; }\n *     TreeNode(int val, TreeNode left, TreeNode right) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\nclass Solution {\n    private int countNodes(TreeNode root){\n        if(root == null){\n            return 0;\n        }\n        return 1 + countNodes(root.left) + countNodes(root.right);\n    }\n    private TreeNode findX(TreeNode root, int x){\n        if(root == null || root.val == x){\n            return root;\n        }\n        TreeNode left = findX(root.left, x);\n        if(left != null){\n            return left;\n        }\n        return findX(root.right, x);\n    }\n    public boolean btreeGameWinningMove(TreeNode root, int n, int x) {\n        TreeNode nodeX = findX(root, x);\n        int leftCount = countNodes(nodeX.left);\n        int rightCount = countNodes(nodeX.right);\n        return (leftCount + rightCount < n / 2) || (leftCount > n - leftCount) || (rightCount > n - rightCount);\n    }\n}\n```
['Tree', 'Depth-First Search', 'Binary Tree', 'Java']