Maximum Depth of Binary Tree 2021-06-06 19:40

Problem Description

public static int maxDepth(TreeNode root) {
    int depth = 0;
    if (root != null) {
        depth++;
        depth = depth + Math.max(maxDepth(root.left), maxDepth(root.right));
    }
    return depth;
}
Runtime Memory
0 ms 45 MB

henryxi leetcode list

EOF