leetcodetreenode-diameter-of-binary-tree:二叉树直径

时间:2021-07-01 09:16:36
【文件属性】:
文件名称:leetcodetreenode-diameter-of-binary-tree:二叉树直径
文件大小:1KB
文件格式:ZIP
更新时间:2021-07-01 09:16:36
系统开源 leetcode 树节点二叉树的直径 给定一棵二叉树,您需要计算树的直径长度。 二叉树的直径是树中任意两个节点之间最长路径的长度。 此路径可能会或可能不会通过根。 Example: Given a binary tree 1 / \ 2 3 / \ 4 5 Return 3, which is the length of the path [4,2,1,3] or [5,2,1,3]. Note: The length of path between two nodes is represented by the number of edges between them. 执行 : /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { int max = 0 ; public int diameterOfBi
【文件预览】:
diameter-of-binary-tree-master
----README.md(1KB)

网友评论