剑指 Offer 55 - I. 二叉树的深度

public int maxDepth(TreeNode root) {
        if(root == null) return 0;
        return 1+Math.max(maxDepth(root.left),maxDepth(root.right));
    }

 

posted @ 2020-08-21 16:20  欣姐姐  阅读(76)  评论(0编辑  收藏  举报