Check whether an undirected graph is a valid tree with no cycles and full connectivity.
Constraints
Example
>>> valid_tree(5, [[0,1],[0,2],[0,3],[1,4]]) True >>> valid_tree(5, [[0,1],[1,2],[2,3],[1,3],[1,4]]) False >>> valid_tree(4, [[0,1],[2,3]]) False
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints