[JAVA] Clean Code, 100% Faster Solution, O(N) Time Complexity
\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() {}\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 */\n\nclass Solution {\n    \n    private int maxDepth (TreeNode root) {\n        \n        if (root == null) {\n            return 0;\n        }\n        \n        return 1 + Math.max (maxDepth (root.left), maxDepth (root.right));\n    }\n    \n    public TreeNode subtreeWithAllDeepest(TreeNode root) {\n        \n        if (root == null) {\n            return root;\n        }\n        \n        int leftDepth = maxDepth (root.left);\n        int rightDepth = maxDepth (root.right);\n        \n        if (leftDepth == rightDepth) {\n            return root;\n        }\n        \n        return leftDepth > rightDepth ? subtreeWithAllDeepest (root.left) : subtreeWithAllDeepest (root.right);\n    }\n}\n```\n\nPlease help to **UPVOTE** if this post is useful for you.\nIf you have any questions, feel free to comment below.\n**HAPPY CODING :)\nLOVE CODING :)**
[]