C++ O(N) Set the ans to false whenever you find an imbalance
\nclass Solution {\npublic:\n    bool ans = true;\n    int solve(TreeNode *root){\n        if(!root)\n            return 0;\n        int lh = solve(root -> left
```\nclass Solution {\npublic:\n    bool ans = true;\n    int solve(TreeNode *root){\n        if(!root)\n            return 0;\n        int lh = solve(root -> left);\n        int rh = solve(root -> right);\n        if(abs(lh - rh ) > 1)\n            ans = false;\n        return 1 + max(lh,rh); \n    }\n    bool isBalanced(TreeNode* root) {\n        solve(root);\n        return ans;\n    }\n};\n```
[]