![在这里插入图片描述](https://img-blog.csdnimg.cn/20200321102257853.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTc3NDcwNg==,size_16,color_FFFFFF,t_70)
迭代
public int MaxDepth(TreeNode root)
{
if(root==null) return 0;
else
{
int left_height = MaxDepth(root.left);
int right_height = MaxDepth(root.right);
return Math.Max(left_height, right_height) + 1;
}
}
提交记录
39 / 39 个通过测试用例
状态:通过
执行用时:120 ms
内存消耗:25.4 MB
提交时间:1 分钟之前