📅  最后修改于: 2022-03-11 14:59:15.780000             🧑  作者: Mango
int getDiameter(TreeNode* root)
{
if(root == NULL)
return(0);
int lheight = getHeight(root->left);
int rheight = getHeight(root->right);
int ldiameter = getDiameter(root->left);
int rdiameter = getDiameter(root->right);
return(max(lheight+rheight+1,max(ldiameter,rdiameter)));
}