int mxheight(Node* root) { if(root==NULL) return 0; return max(mxheight(root->left), mxheight(root->right))+1; } class Solution { public: // Function to return the diameter of a Binary Tree. int diameter(Node* root) { // Your code here if(root==NULL) return 0; int p=mxheight(root->left)+mxheight(root->right)+1; return max(p, max(diameter(root->left), diameter(root->right))); } };