you give direct graph n node number 0 n 1 node outgoing edgethe graph represent give 0indexed array edge size n indicate direct edge node node edgesi if outgoing edge edgesi 1you give integer node1 node2return index node reach node1 node2 maximum distance node1 node node2 node minimize if multiple answer return node small index possible answer exist return 1note edge contain cycle Example 1input edge 2231 node1 0 node2 1output 2explanation the distance node 0 node 2 1 distance node 1 node 2 1the maximum distance 1 it prove node small maximum distance 1 return node 2Example 2input edge 121 node1 0 node2 2output 2explanation the distance node 0 node 2 2 distance node 2 0the maximum distance 2 it prove node small maximum distance 2 return node 2 Constraintsn edgeslength2 n 1051 edgesi nedgesi i0 node1 node2 n