Company: uber_13oct
Difficulty: medium
Minimum Reversal Problem Description Optimize a directed graph representing a neural network by selecting a root node that minimizes the number of edge reversals needed. The graph has n nodes numbered from 1 to n and n-1 edges, where the i th edge connects node g_from[i] to g_to[i]. Select any node as the root, then reverse as many edges as necessary to make all edges flow away from the root. Find the root node choice that requires the minimum number of edge reversals. Complete the function getMinInversions in the editor with the following arguments: int a_nodes : the number of nodes in the graph List<Integer> g_from : a list representing the starting nodes of the directed edges List<Integer> g_to : a list representing the ending nodes of the directed edges Returns: int : the minimum number of edges that must be inverted Examples Example 1: Consider a graph with: g_nodes = 4 g_from = [1, 2, 3] g_to = [4, 4, 4] Explanation: The graph has edges 1->4, 2->4, and 3->4. If node 2