Loading...

递归-二叉树的最大深度

在这里插入图片描述

求解代码

1
2
3
4
5
6
7
public int maxDepth (TreeNode root) {
        if(root==null){
			return 0;
		}

		return Math.max(maxDepth(root.left),maxDepth(root.right))+1;
    }
最后更新于 2026-04-05 17:35:33
Code Road Record