Search⌘ K
AI Features

Solution: Tree Diameter

Solution: Tree Diameter gives an undirected tree through its edges and asks you to return the diameter: the number of edges on the longest path between any two nodes.

Statement

Given an undirected tree with nn nodes labeled from 00 to n−1n - 1, represented by a 2D array edges where edges.length==n−1 ...