Check for Balanced tree

PHOTO EMBED

Sun Jul 10 2022 07:34:22 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

class Solution{
    public:
    int height(Node * temp)
    {
        if(temp==NULL) return 0;
        int lh=height(temp->left);
        int rh=height(temp->right);
        return 1+max(lh,rh);
    }
    //Function to check whether a binary tree is balanced or not.
    bool isBalanced(Node *root)
    {
        
        if(root==NULL) return 1;
        int lh=height(root->left);
        int rh=height(root->right);
        if(abs(lh-rh)<=1 && isBalanced(root->left) && isBalanced(root->right)) return 1;
        return 0;
        //  Your Code here
    }
};
content_copyCOPY

https://practice.geeksforgeeks.org/problems/check-for-balanced-tree/1/