My code as follows:

Test case is :{2,1,3}

I tried in eclipse, it works very well ,however, here return false. I don't know why?

```
public class Solution {
public static boolean isbalanced = true;
public boolean isBalanced(TreeNode root) {
if(null == root)
return true;
getdepth(root,0);
return isbalanced;
}
public int getdepth(TreeNode root, int dep){
if(root ==null)
return dep;
int left = getdepth(root.left,1+dep);
int right = getdepth(root.right,1+dep);
if(Math.abs(left-right)>1){
isbalanced= false;
}
return Math.max(left,right);
}}
```