Algorithm · ByteDance · Medium
You are given an undirected graph consisting of n vertices numbered from 0 to n - 1 and m edges. Decide whether there exists a path from a specified source vertex to a specified destination vertex. A path is a sequence of vertices where consecutive vertices are directly connected by an edge; you may traverse any number of intermediate vertices. If the source and destination are the same vertex, the answer is true by definition. Implement pathExists(n, edges, source,…