Graph Valid Tree
Medium
You are given an integer n and a list of undirected edges edges where nodes are labeled 0 to n - 1.
Return true if the edges form a valid tree, and false otherwise.
A valid tree is an undirected graph that is connected and contains no cycles. Equivalently, for n nodes it must have exactly n - 1 edges and be connected.
Example:
Input:5 [[0,1],[0,2],[0,3],[1,4]]Output:true
Constraints:
1 <= n <= 20000 <= edges.length <= 10^4edges[i] = [u, v]with0 <= u, v < n