二叉树深度
public int treeDepth(TreeNode root) {
if (root == null) return 0;
return Math.max(treeDepth(root.left), treeDepth(root.right)) + 1;
}
最后更新于
这有帮助吗?
public int treeDepth(TreeNode root) {
if (root == null) return 0;
return Math.max(treeDepth(root.left), treeDepth(root.right)) + 1;
}
最后更新于
这有帮助吗?