A graph has n nodes numbered 0 to n - 1 and undirected edges. Return True if there is a path from source to destination.
For n = 3, edges = [[0, 1], [1, 2], [2, 0]], source = 0 and destination = 2 the answer is True.
Example 1
Input:
valid_path(3, [[0, 1], [1, 2], [2, 0]], 0, 2)
Output:
True
Example 2
Input:
valid_path(6, [[0, 1], [0, 2], [3, 5], [5, 4], [4, 3]], 0, 5)
Output:
False
1 <= n <= 1000000 <= len(edges) <= 2000000 <= source, destination < nNo results yet
Run your code to check it against the examples, or submit to run every test.