Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
二话不说,递归求解,一次通过。
public int maxDepth(TreeNode root) {
if (root == null)
return 0;
if (root.left == null && root.right == null)
return

这篇博客介绍了如何解决LeetCode上的104题,即寻找二叉树的最大深度。通过递归方法,博主成功一次性解决了问题,并提到这种方法与其他解法相似。
订阅专栏 解锁全文
698

被折叠的 条评论
为什么被折叠?



