2
def shortestAlternatingPaths(3
self, n: int, redEdges: List[List[int]], blueEdges: List[List[int]]5
g = [[[] for _ in range(2)] for _ in range(n)]11
distance = [float("inf") for _ in range(n)]20
node, dist, red = q.get()22
neighbours = g[node][0]26
neighbours = g[node][1]29
for neighbour in neighbours:30
if dist + 1 < distance[neighbour]:31
distance[neighbour] = dist + 132
q.put((neighbour, dist + 1, not red))33
if not (neighbour in curr):34
q.put((neighbour, dist + 1, not red))36
if distance[i] == float("inf"):