package com.fishercoder.solutions;

import com.fishercoder.common.classes.TreeNode;

/**104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.
 The maximum depth is the number of
 nodes along the longest path from the root node down to the farthest leaf node.
 */
public class _104 {
    
    //more verbose version
    public int maxDepth(TreeNode root) {
        if(root == null) return 0;
        int leftDepth = maxDepth(root.left)+1;
        int rightDepth = maxDepth(root.right)+1;
        return Math.max(1, Math.max(leftDepth, rightDepth));
    }
    
    //more concise version
    public int maxDepth_shorter_version(TreeNode root) {
        if(root == null) return 0;
        return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
    }

}

@@ -81,16 +81,20 @@
 de;%0A%0A/**
+%0A * 
 104. Max
@@ -119,16 +119,19 @@
 ry Tree%0A
+ * 
 Given a 
@@ -167,16 +167,18 @@
  depth.%0A
+ *
  The max
@@ -204,17 +204,16 @@
 umber of
-%0A
  nodes a
@@ -313,39 +313,8 @@
 4 %7B%0A
-    %0A    //more verbose version
 %0A   
@@ -365,295 +365,9 @@
   if
-(root == null) return 0;%0A        int leftDepth = maxDepth(root.left)+1;%0A        int rightDepth = maxDepth(root.right)+1;%0A        return Math.max(1, Math.max(leftDepth, rightDepth));%0A    %7D%0A    %0A    //more concise version%0A    public int maxDepth_shorter_version(TreeNode root) %7B%0A        if
+ 
 (roo

edit 104