1971. Find if Path Exists in Graph

Practice Find if Path Exists in Graph for free on NudgeCode: Easy, Graph pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

An undirected graph has nodes 0 .. n-1; each edges[i] = [u, v] connects u and v. Return true if there is a path from source to destination, otherwise false.

Example

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  ->  false

Constraints