Solution: Minimum Height Trees
Let's solve the Minimum Height Trees problem using the Topological Sort pattern.
Statement
You are given as the number of nodes and a 2D array of edges representing a tree having the following properties:
-
It is an acyclic, undirected graph containing nodes and edges.
-
The nodes are labeled from to .
-
An edge at the index is represented as , which denotes that there is an undirected edge connecting the nodes ...