💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
[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 } ```