```
class Solution {
public:
int depth(TreeNode* root){
return root?max(depth(root->left),depth(root->right))+1:0;
}
bool isBalanced(TreeNode* root){
return root?abs(depth(root->left)-depth(root->right))<=1&&isBalanced(root->left)&&isBalanced(root->right):1;
}
```

};