Ezvor

261. Graph Valid Tree

MediumDepth-First Search Preparing judge… LeetCode
Depth-First SearchBreadth-First SearchUnion-FindGraph Theory

Hints

Hint 1
Given n = 5 and edges = [[0, 1], [1, 2], [3, 4]], what should your return? Is this case a valid tree?
Hint 2
According to the definition of tree on Wikipedia: “a tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree.”