You are given an integer n representing the number of nodes in a directed graph, with nodes labeled from n redEdges and blueEdges, where:
redEdges[i] = [a_i, b_i] indicates a directed red edge from node a_i to node b_i.
blueEdges[j] = [u_j, v_j] indicates a directed blue edge from node u_j to node v_j.
Find the shortest path from node x such that the colors of the edges along the path strictly alternate between red and blue.
Return an array answer of length n, where answer[x] is the length of the shortest alternating path from node x, or
Constraints:
n
redEdges.length, blueEdges.length
redEdges[i].length blueEdges[j].length
a_i, b_i, u_j, v_j n
You are given an integer n representing the number of nodes in a directed graph, with nodes labeled from n redEdges and blueEdges, where:
redEdges[i] = [a_i, b_i] indicates a directed red edge from node a_i to node b_i.
blueEdges[j] = [u_j, v_j] indicates a directed blue edge from node u_j to node v_j.
Find the shortest path from node x such that the colors of the edges along the path strictly alternate between red and blue.
Return an array answer of length n, where answer[x] is the length of the shortest alternating path from node x, or
Constraints:
n
redEdges.length, blueEdges.length
redEdges[i].length blueEdges[j].length
a_i, b_i, u_j, v_j n