[C++] O(n) Easier to understand with explanation. 93%
\nclass Solution {\n    int maxDepth = 0;\n    \n    TreeNode* helper(TreeNode* root, int& depth) {\n        if (root == NULL) {\n            return NULL;\n    
```\nclass Solution {\n    int maxDepth = 0;\n    \n    TreeNode* helper(TreeNode* root, int& depth) {\n        if (root == NULL) {\n            return NULL;\n        }\n        \n        depth++; // for this node.\n        // identify if this is a leaf node.\n        if (root->left == NULL && root->right == NULL) {\n            return root;\n        }\n        \n        int leftDepth = depth; \n        // if either exist, we want to ask the children.\n        TreeNode* left = helper(root->left, leftDepth);\n        \n        int rightDepth = depth;\n        TreeNode* right = helper(root->right, rightDepth);\n        \n        // if both sides are equal then this node is the contendor for LCA.\n        if (rightDepth == leftDepth) {\n            depth = leftDepth;\n            return root;\n        }\n        \n        if (rightDepth > leftDepth) {\n            depth = rightDepth;\n            return right;\n        } else {\n            depth = leftDepth;\n            return left;\n        }\n        \n        // now when it returns to the parent, the parent has the choice again to check against\n        // its left and right. And again if the length from both the sides is equal, the\n        // LCA contender will change, until it reaches the root.\n    }\npublic:\n    TreeNode* subtreeWithAllDeepest(TreeNode* root) {\n        // so for a node to know the deepest node, the depth of its left and right subtrees should be same.\n        // if the right is deeper than the left, then its not the deepest.\n        // so every node passes the max depth it has seen to the parent. \n        int depth = 0;\n        return helper(root, depth);\n    }\n};\n```
['C']