There is a bi-directional graph with n vertices labeled 0 to n-1. Given source and destination, return true if there is a valid path from source to destination.
n=3, edges=[[0,1],[1,2],[2,0]], source=0, destination=2trueparent[i]=i for all nodes(a,b): union(parent, a, b)find(parent,src)==find(parent,dst)Union-Find tracks connected components. After processing all edges, src and dst are in the same component iff they're connected. Path compression makes lookups near O(1).