Company: cashfree_29oct
Difficulty: medium
Maximum Difference Problem Description Given a set of nodes and a set of edges between pairs of nodes, your task is to first identify the connected components in the graph. A connected component is a group of nodes that are all linked, either directly or through other nodes in the group. For each connected component, calculate the difference between its largest and smallest node values, and return the maximum of these differences. Complete the maximumDifference function below. The function is expected to return an INTEGER . The function accepts an unweighted integer graph g as parameter. For the unweighted graph, <name> : 1. The number of nodes is <name>_nodes . 2. The number of edges is <name>_edges . 3. An edge exists between <name>_from[i] and <name>_to[i] . int maximumDifference(int g_nodes, vector<int> g_from, vector<int> g_to) { // Function implementation } Examples Example 1: Input: g_nodes = 4 g_from = [1, 2] g_to = [2, 3] Output: 2 Exp