func max(a int,b int)int{
if a>=b{
return a
}
return b
}
func maxall(a int,b int,c int)int{
return max(max(a,b),c)
}
func maxDepth1(root *TreeNode) int {
if root==nil{
return 0
}
l := maxDepth1(root.Left)
r:= maxDepth1(root.Right)
return int(max(l,r)+1)
}
func diameterOfBinaryTree(root *TreeNode) int {
if root==nil{
return 0
}
return maxall(diameterOfBinaryTree(root.Right),diameterOfBinaryTree(root.Left),maxDepth1(root.Right)+maxDepth1(root.Left) )
}