Find if Path Exists in Graph
EasyGraphs
Decode it first. Clues, constraints, pattern and plan before any code.A graph has n nodes labelled 0 to n - 1 and a list of undirected edges, where [u, v] joins u and v. Return true if there is a path from source to destination, and false otherwise.
n = 3, edges = [[0, 1], [1, 2], [2, 0]], source = 0, destination = 2 → true
n = 6, edges = [[0, 1], [0, 2], [3, 5], [5, 4], [4, 3]], source = 0, destination = 5 → falseConstraints
1 <= n <= 2 * 10^50 <= edges.length <= 2 * 10^50 <= source, destination < n- No duplicate edges and no self-loops