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

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

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

你可能感兴趣的:(#,剑指offer,算法)