```
public class Solution {
public int maxDepth(TreeNode root) {
return helper(root,0);
}
public int helper(TreeNode root,int deep)
{
if(root==null)
return deep;
else
return Math.max(helper(root.left,deep+1),helper(root.right,deep+1));
}
}
```