Best Solution with 2 approaches
Approach #1\n\nclass Solution {\nprivate:\n    int height(TreeNode* root){\n        if(root==NULL)\n            return 0;\n        \n        int left = height(r
## **Approach #1**\n```\nclass Solution {\nprivate:\n    int height(TreeNode* root){\n        if(root==NULL)\n            return 0;\n        \n        int left = height(root->left);\n        int right = height(root->right);\n        \n        int ans = max(left,right) + 1;\n        \n        return ans;\n    }\npublic:\n    bool isBalanced(TreeNode* root) {\n        if(root==NULL)\n            return true;\n        \n        bool left = isBalanced(root->left);\n        bool right = isBalanced(root->right);\n        \n        bool diff = abs (height(root->left) - height(root->right)) <= 1;\n        \n        if(left && right && diff){\n            return true;\n        }\n        else{\n            return false;\n        }\n    }\n};\n```\n\n## **Approach #2** (Using Pair)(optimal approach)\n```\nclass Solution {\n\npublic:\n    pair<bool,int> checkBalanced(TreeNode* root){\n        if(root==NULL){\n            pair<bool,int> p = make_pair(true,0);\n            return p;\n        }\n        \n        pair<int,int> left = checkBalanced(root->left);\n        pair<int,int> right = checkBalanced(root->right);\n        \n        bool leftAns = left.first;\n        bool rightAns = right.first;\n        \n        bool diff = abs (left.second - right.second) <= 1;\n        \n        pair<bool,int> ans;\n        ans.second = max(left.second,right.second) + 1;\n        \n        if(leftAns && rightAns && diff){\n            ans.first = true;\n        }\n        else{\n            ans.first = false;\n        }\n        \n        return ans;\n    }\n    bool isBalanced(TreeNode* root) {\n        return checkBalanced(root).first;\n    }\n};\n```\n\n# ****PLEASE UPVOTE
['Recursion', 'C', 'Binary Tree']