You are given a directed graph of n nodes labeled from n
The graph is represented by an array edges of length n, where edges[i] denotes a directed edge from node i to node edges[i]. If node i has no outgoing edge, then edges[i] ==
You are also given two node identifiers, node1 and node2.
Find the node that is reachable from both node1 and node2 such that the maximum of the distance from node1 to this node and the distance from node2 to this node is minimized. If multiple nodes satisfy this condition, return the one with the smallest index. If no common node is reachable from both node1 and node2, return
Constraints:
n edges.length
n
edges[i]
edges[i] i
node1, node2
You are given a directed graph of n nodes labeled from n
The graph is represented by an array edges of length n, where edges[i] denotes a directed edge from node i to node edges[i]. If node i has no outgoing edge, then edges[i] ==
You are also given two node identifiers, node1 and node2.
Find the node that is reachable from both node1 and node2 such that the maximum of the distance from node1 to this node and the distance from node2 to this node is minimized. If multiple nodes satisfy this condition, return the one with the smallest index. If no common node is reachable from both node1 and node2, return
Constraints:
n edges.length
n
edges[i]
edges[i] i
node1, node2