Problem
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.
Example 1
- Input
- n = 3, edges = [[0, 1], [1, 2], [2, 0]], source = 0, destination = 2
- Output
- true
Example 2
- Input
- n = 6, edges = [[0, 1], [0, 2], [3, 5], [5, 4], [4, 3]], source = 0, destination = 5
- Output
- false
Constraints
1 <= n <= 2 * 10^50 <= edges.length <= 2 * 10^50 <= source, destination < nNo duplicate edges and no self-loops