LeetCode - 104. 二叉树的最大深度

104. 二叉树的最大深度

public class Solution {

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

    public int maxDepth(TreeNode root) {
        return findDepth(root);
    }
}


猜你喜欢

转载自blog.51cto.com/tianyiya/2172947