JAVA simple merge solution


  • 0
    L

    int deep1=0;
    public int maxDepth(TreeNode root) {
    maxDepth(root,0);

    return deep1;
        
    }
    

    public void maxDepth(TreeNode root,int deep)
    {
    if(root!=null)//肯定是用递归解决的
    deep++;
    else
    {
    if(deep>deep1)
    deep1=deep;
    return;
    }
    maxDepth(root.left,deep);
    maxDepth(root.right,deep);

     }
    

    }


Log in to reply
 

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