@Test public void noTreeNoDepth() throws Exception { Solution solution = new Solution(); int i = solution.maxDepth(null); assertThat(i, is(0)); }
public int maxDepth(TreeNode root) { if (root == null) { return 0; } else { int leftDepth = maxDepth(root.left); int rightDepth = maxDepth(root.right); return 1 + Integer.max(leftDepth, rightDepth); } }
Solution { public int maxDepth(TreeNode root) { if (root == null) { return 0; } else { int leftDepth = maxDepth(root.left); int rightDepth = maxDepth(root.right); return 1 + Integer.max(leftDepth, rightDepth); } } }
Solution { public int maxDepth(TreeNode root) { if (root == null) { return 0; } else { int leftDepth = maxDepth(root.left); int rightDepth = maxDepth(root.right); return 1 + Integer.max(leftDepth, rightDepth); } }  }
Solution { public int maxDepth(TreeNode root) { if (root == null) { return 0; } else { int leftDepth = maxDepth(root.left); int rightDepth = maxDepth(root.right); return 1 + Integer.max(leftDepth, rightDepth); } }  int maxDepth(TreeNode root); }
Solution { public int maxDepth(TreeNode root) { if (root == null) { return 0; } else { int leftDepth = maxDepth(root.left); int rightDepth = maxDepth(root.right); return 1 + Integer.max(leftDepth, rightDepth); } }  int maxDepth(TreeNode root);  }