```
public class Solution {
boolean bal;
public boolean isBalanced(TreeNode root) {
bal = true;
int a = findDepth(root);
return bal;
}
private int findDepth(TreeNode root){
if (root==null) return 0;
int dleft = findDepth(root.left) + 1;
int dright = findDepth(root.right) + 1;
if(Math.abs(dleft-dright)>1){
bal = false;
return 0;
}
return Math.max(dleft,dright);
}
}
```