class Solution {
public int findCenter(int[][] edges) {
//因为每条边就两个顶点,而且每条边都会有公共顶点
//那么整个图的中心结点也就是两条边中的公共结点
if (edges[0][0] == edges[1][0] || edges[0][0] == edges[1][1])
return edges[0][0];
else
return edges[0][1];
}
}
找出星型图的中心节点
最新推荐文章于 2022-03-27 20:46:32 发布