https://leetcode.com/problems/minimum-height-trees/ 有trick 对graph不熟悉。再看几遍。 参考http://bookshadow.com/weblog/2015/11/26/leetcode-minimum-height-trees/ 基本思路是“逐层删去叶子节点,直到剩下根节点为止” 有点类似于拓扑排序 最终剩下的节点个数可能为1或者2 时间复杂度:O(n),其中n为...
[leetcode] 310. Minimum Height Trees Description For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum height trees (MHTs). Given such a g...
LeetCode: 310. Minimum Height Trees 题目描述 For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum height trees (MHTs). Given such a graph...