I tested my code in local,it comes out the right answer,but it can't run on the OJ,any help will be appreciated

```
public int maxDepth(TreeNode root) {
int left=0;
int right=0;
if(root==null) return 0;
if(root.val==0)root.val=1;
if(root.left!=null){
root.left.val=root.val+1;
left=maxDepth(root.left);
}
if(root.right!=null){
root.right.val=root.val+1;
right=maxDepth(root.right);
}
if(right!=0||left!=0){
if(right>=left)return right;
else return left;
}
return root.val;
}
```

the OJ says that when input is {3,9,15,3,#,#,9,7} the expected answer is 3，but my code runs to get 5