test cases are not passing
question–>
https://practice.geeksforgeeks.org/problems/diameter-of-binary-tree/1#
code–>
pair<int,int> diameter1(Node* root) {
pair<int,int> p;
if(root==NULL){
p.first=p.second=0;
return p;
}
pair<int,int> left=diameter1(root->left);
pair<int,int> right=diameter1(root->right);
p.first=max(left.first,right.first)+1;
p.second=max(left.first+right.first,max(right.second,left.second));
return p;
}
int diameter(Node* root){
pair<int,int> p=diameter1(root);
return p.second;
}