```
class Solution {
public boolean isBalanced(TreeNode root) {
if(root == null) return true;
int diff = Math.abs((getLevel(root.left) - getLevel(root.right)));
return diff <= 1? isBalanced(root.left) && isBalanced(root.right): false;
}
private int getLevel(TreeNode root){
if(root == null) return 0;
return Math.max(1 + getLevel(root.left), 1 + getLevel(root.right));
}
}
```