C++ DFS solution
class Solution {\n    public:\n        bool isBalanced(TreeNode* root) {\n            int height = 0;\n            return checkBalance(root, height);\n        }
    class Solution {\n    public:\n        bool isBalanced(TreeNode* root) {\n            int height = 0;\n            return checkBalance(root, height);\n        }\n        \n        bool checkBalance(TreeNode* root, int& height) {\n            if (root == NULL) {\n                height = 0;\n                return true;\n            }\n            int leftHeight = 0;\n            int rightHeight = 0;\n            if (!checkBalance(root->left, leftHeight)) return false;\n            if (!checkBalance(root->right, rightHeight)) return false;\n            if ( abs(leftHeight - rightHeight) > 1 ) return false;\n            height = max(leftHeight, rightHeight) + 1;\n            return true;\n        }\n    };
['C++']