class Solution {

public:

```
bool isBalanced(TreeNode* root) {
if(root==NULL)
{
return true;
}
if((root->left == NULL)&&(root->right ==NULL))
{
return true;
}
else
{
return height_Max(root)-height_Min(root)<2;
}
}
int height_Max(TreeNode* rt)
{
if(rt==NULL)
return 0;
else
return 1+max(height_Max(rt->left),height_Max(rt->right));
}
int height_Min(TreeNode* rt1)
{
if(rt1==NULL)
{
return 0;
}
else
{
return 1+min(height_Min(rt1->left),height_Min(rt1->right));
}
}
```

};