← ALL NOTES
Depth-First Search

2359. Find Closest Node to Given Two Nodes

Given a functional graph: edges[i] is the single outgoing edge from node i (or −1). Starting from node1 and node2, follow the edges. Find a node reachable from both such that the maximum of the two…

Loading…