Graph Valid Tree (#261)
You have a graph of n
nodes labeled from 0
to n - 1
. You are given an integer n
and a list of edges
where edges[i] = [ai, bi]
indicates that there is an undirected edge between nodes ai
and bi
in the graph.
Return true
if the edges of the given graph make up a valid tree, and false
otherwise.
Note: This is a premium LeetCode problem. The description is provided for educational purposes.
Company Tags: Google, Amazon
Core Concept: Graph, DFS, BFS, Union-Find