【leetcode】二叉树的直径
int recursion(struct TreeNode* root, int* max){ if (!root) return 0; int left=recursion(root->left,max); int right=recursion(root->right,max); if(left+right>*max) *max=left+right; return (left>right)?left+1 :right+1; } int diameterOfBinaryTree(struct TreeNode* root){ int max=0; recursion(root,&max); return max; }