1
# Runtime: 1647 ms (Top 68.5%) | Memory: 108.91 MB (Top 50.2%)5
def validPath(self, n, edges, start, end):8
:type edges: List[List[int]]15
# store the undirected edges for both vertices26
# create a queue as we will apply BFS29
curr = q.pop(0) # pop the first element as we do in queue30
if curr == end: # if its the end then we can return True33
curr in d and not visited[curr]34
): # else if it is not the end then check whether its visited or not37
) # add the adjacent vertices of the current node to the queue39
True # mark this curr vertex as visited = True, so that we dont visit this vertex again41
return False # return False if the queue gets empty and we dont reach the end