leetcode-104-easy

Maximum Depth of Binary Tree
思路一: 递归

public int maxDepth(TreeNode root) {
    if (root == null) return 0;

    return 1 + Math.max(maxDepth(root.left), maxDepth(root.right));
}
posted @ 2022-10-19 07:32  iyiluo  阅读(22)  评论(0)    收藏  举报