Skip to content

Commit 02d0fab

Browse files
authored
Create README.md
1 parent b64c5f6 commit 02d0fab

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
有一个无向的 **星型** 图,由 ```n``` 个编号从 ```1``````n``` 的节点组成。星型图有一个 **中心** 节点,并且恰有 ```n - 1``` 条边将中心节点与其他每个节点连接起来。
2+
3+
给你一个二维整数数组 ```edges``` ,其中 ```edges[i] = [ui, vi]``` 表示在节点 ```ui``````vi``` 之间存在一条边。请你找出并返回 ```edges``` 所表示星型图的中心节点。
4+
5+
 
6+
7+
**示例 1:**
8+
9+
![img](https://github.com/Zhenghao-Liu/LeetCode_problem-and-solution/blob/master/1790.找出星型图的中心节点/1791_1.png)
10+
```
11+
输入:edges = [[1,2],[2,3],[4,2]]
12+
输出:2
13+
解释:如上图所示,节点 2 与其他每个节点都相连,所以节点 2 是中心节点。
14+
```
15+
**示例 2:**
16+
```
17+
输入:edges = [[1,2],[5,1],[1,3],[1,4]]
18+
输出:1
19+
```
20+
21+
**提示:**
22+
23+
* ```3 <= n <= 10^5```
24+
* ```edges.length == n - 1```
25+
* ```edges[i].length == 2```
26+
* ```1 <= ui, vi <= n```
27+
* ```ui != vi```
28+
* 题目数据给出的 ```edges``` 表示一个有效的星型图
29+
30+
来源:力扣(LeetCode)
31+
链接:https://leetcode-cn.com/problems/find-center-of-star-graph
32+
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

0 commit comments

Comments
 (0)