Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite631d17

Browse files
refactor 261
1 parent36f810c commite631d17

File tree

1 file changed

+0
-23
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-23
lines changed

‎src/main/java/com/fishercoder/solutions/_261.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
packagecom.fishercoder.solutions;
22

3-
/**
4-
*261. Graph Valid Tree
5-
*
6-
* Given n nodes labeled from 0 to n - 1 and a list of undirected edges
7-
* (each edge is a pair of nodes),
8-
* write a function to check whether these edges make up a valid tree.
9-
10-
For example:
11-
12-
Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], return true.
13-
14-
Given n = 5 and edges = [[0, 1], [1, 2], [2, 3], [1, 3], [1, 4]], return false.
15-
16-
Hint:
17-
18-
Given n = 5 and edges = [[0, 1], [1, 2], [3, 4]], what should your return? Is this case a valid tree?
19-
According to the definition of tree on Wikipedia:
20-
“a tree is an undirected graph in which any two vertices are connected by exactly one path.
21-
In other words, any connected graph without simple cycles is a tree.”
22-
23-
Note: you can assume that no duplicate edges will appear in edges.
24-
Since all edges are undirected, [0, 1] is the same as [1, 0] and thus will not appear together in edges.
25-
*/
263
publicclass_261 {
274

285
publicstaticclassSolution1 {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp