Solution using C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    int height(TreeNode* root)\n    {\n        if (!root) return 0;\n        return 1 + max(height(root->left), height(root->right));\n    }\n    bool isBalanced(TreeNode* root) {\n        if (!root) return true;\n        int balance = height(root->left) - height(root->right);\n        if (balance > 1 || balance < -1) return false;\n        if (!isBalanced(root->left) || !isBalanced(root->right)) return false;\n        return true;\n    }\n};\n```
['C++']