My java solution


  • 0
    M

    public int maxDepth(TreeNode root)
    {
    int deepth = 0;
    if(null == root){

    		return deepth;
    	}
    	deepth += 1;
    	
    	int left = maxDepth(root.left);
    	int right = maxDepth(root.right);
    	
    	int recursionDeepth = (left > right)?left:right;
    	
    	deepth += recursionDeepth;
    	
    	return deepth;
    }

Log in to reply
 

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