Go 100% 0ms/3MB solution
\n/**\n * Definition for a binary tree node.\n * type TreeNode struct {\n *     Val int\n *     Left *TreeNode\n *     Right *TreeNode\n * }\n */\n// var maxDep
```\n/**\n * Definition for a binary tree node.\n * type TreeNode struct {\n *     Val int\n *     Left *TreeNode\n *     Right *TreeNode\n * }\n */\n// var maxDepth int = 0\n// var level int = 0\n// var recmap map[int]TreeNode\nfunc subtreeWithAllDeepest(root *TreeNode) *TreeNode {\n    _,maxDepth := search(root)\n    return maxDepth\n}\n\nfunc search(root *TreeNode)(int,*TreeNode){\n    if root == nil{\n        return 0,nil\n    }\n    ldep,lnode := search(root.Left)\n    rdep,rnode := search(root.Right)\n    max := Max(ldep, rdep) + 1\n    if ldep == rdep{\n        return max,root\n    }\n    if ldep > rdep{\n        return max,lnode\n    }else{\n        return max,rnode\n    }\n}\n\nfunc Max(x, y int) int {\n    if x > y {\n        return x\n    }\n    return y\n}\n```\n
[]