...

/

Solution Review: Check if Given Undirected Graph is a Tree or Not

Solution Review: Check if Given Undirected Graph is a Tree or Not

Let's solve the Graph Valid Tree problem.

Statement

Given an undirected graph containing nn nodes labeled from 00 to n1n - 1, determine whether the graph is a valid tree or not. Return TRUE if the edges of the given graph make up a valid tree, and FALSE otherwise.

A graph is a valid tree when all the nodes are connected and there is no cycle between them.

Constraints:

Let nn be the number of nodes in the undirected graph, where: ...