```
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
int max = 0;
public void getMax(TreeNode root, int count){
if(count > max){
max = count;
}
if(root.left != null){
count++;
getMax(root.left, count);
}
if(root.right != null){
count++;
getMax(root.right, count);
}
if(root.left == null && root.right == null){
return;
}
}
public int maxDepth(TreeNode root) {
if(root == null){
return 0;
}
getMax(root, 1);
return max;
}
}
```

Whats wrong with this solution as oppose to this one.

```
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
int max = 0;
public void getMax(TreeNode root, int count){
if(count > max){
max = count;
}
if(root.left != null){
getMax(root.left, count + 1);
}
if(root.right != null){
getMax(root.right, count + 1);
}
if(root.left == null && root.right == null){
return;
}
}
public int maxDepth(TreeNode root) {
if(root == null){
return 0;
}
getMax(root, 1);
return max;
}
}
```

The first one fails and the second one passes. Also, I know i'm not suppose to use globals and I can use Math.max. Just want to know the difference between incrementing count and just passing in the next number.

Thanks guys.