The diameter of a tree is the number of edges in the longest path in that tree. There is an undirected tree ofnnodes labeled from0ton - 1. You are given a 2D arrayedgeswhereedges.length == n - 1andedges[i] = [ai, bi]indicates that there is an undirected edge between nodesaiandb...
原题链接在这里:https://leetcode.com/problems/tree-diameter/ 题目: Given an undirected tree, return its diameter: the number of edges in a longest path in that tree. The tree is given as an array ofedgeswhereedges[i] = [u, v]is a bidirectional edge between nodesuandv. Each node has...
tree diameter, now, this tree is very much like a graph, but it’s still a tree, it’s very much like this N-ary tree. so what’s the difference between them? the input. the input of that tree diameter is int[][] edges, it has no root, it can be start from any node. the...