```
public class Solution {
boolean answer = true;
public boolean isBalanced(TreeNode root) {
checkHeigth(root, 0);
return answer;
}
private int checkHeigth(TreeNode node, int h){
if(node == null) return h;
int left = 0, right = 0;
if(answer){
left = checkHeigth(node.left, h+1);
right = checkHeigth(node.right, h+1);
if(Math.abs(left - right) > 1) answer = false;
}
return Math.max(left, right);
}
}
```