I used recursive method to compute each node's depth. Here is my code:

```
public class Solution {
public int minDepth(TreeNode root) {
if(root == null)
return 0;
int i = getMinDepth(root.left);
int j = getMinDepth(root.right);
if(i == 0 || j == 0)
return 1+i+j;
return Math.min(i,j) + 1;
}
private int getMinDepth(TreeNode root) {
if(root == null)
return 0;
return Math.min(getMinDepth(root.left), getMinDepth(root.right)) + 1;
}
```

}

this code can not pass the input {1,2,3,4,#,#,5}. Expected is 3, but my output is 2.

And also I can not know the input {1,2,3,4,#,#,5} is inorder Traversal or postorder or preorder.