Medium
Given n nodes labeled 0..n-1 and a list of undirected edges, return true if the graph is a valid tree (fully connected and acyclic).
Input: n = 5, edges = [[0,1],[0,2],[0,3],[1,4]] Output: true
Input: n = 5, edges = [[0,1],[1,2],[2,3],[1,3],[1,4]] Output: false