My recursive simple solution

  • 0

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

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.