摘要: 题目链接 543. 二叉树的直径 思路 创建全局变量 diameter 以记录左子树高度加右子树高度,并在 DFS 过程中维护此变量。 代码 class Solution { int diameter; public int diameterOfBinaryTree(TreeNode root) { 阅读全文
posted @ 2023-01-18 10:11 Frodo1124 阅读(31) 评论(0) 推荐(0) 编辑