Leetcode543. 二叉树的直径(HOT100)
链接 代码: class Solution { public:int res 0;int diameterOfBinaryTree(TreeNode* root) {dfs(root);return res;}int dfs(TreeNode* root){if(!root)return 0;int left dfs(root->left),right dfs(root->right);res max(res,leftright);return max(…
2025-07-03