Company: PayPal SWE Intern_30oct
Difficulty: medium
Reverse Edges Problem Description A country can be represented as a graph with g_nodes cities connected by g_edges - 1 uni-directional edges. The i -th edge connects cities g_from[i] and g_to[i] . If the roads were bi-directional, every node would be reachable from every other node. The resulting graph would be a tree. For each city i ( 1 ), find the minimum number of edges that must be reversed so that it is possible to travel from city i to any other city using the directed edges. Complete the function reverseEdges in the editor with the following parameters: int g_nodes : the number of nodes int g_edges : the number of edges in the graph int g_from[] : the origin node of each directed edge int g_to[] : the terminal node of each directed edge Returns int[] : g_nodes integer, the minimum number of edges to reverse so that every other node is reachable from the current source node. Examples Example 1: (Sample Case 0) Input: 3 2 2 1 1 3 Output: 1 0 1 Explanation: Consider the graph with