标签:important etc fabs lse one amp tco root color
int height(struct TreeNode* root) {
if (root == NULL) {
return 0;
} else {
return fmax(height(root->left), height(root->right)) + 1;
}
}
bool isBalanced(struct TreeNode* root) {
if (root == NULL) {
return true;
} else {
return fabs(height(root->left) - height(root->right)) <= 1 && isBalanced(root->left) && isBalanced(root->right);
}
}
标签:important etc fabs lse one amp tco root color
原文地址:https://www.cnblogs.com/ganxiang/p/13518258.html