ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
[TOC] ## 二叉树的最大深度 ``` /** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ func maxDepth(root *TreeNode) int { if root ==nil{ return 0 } left:=maxDepth(root.Left) right:=maxDepth(root.Right) return max(left,right)+1 } func max(a,b int)int{ if a>b{ return a } return b } ```