Company: Publicis_sapient_22nov
Difficulty: medium
Constructing a Network Problem Description Given a set of computers that need to be connected to form a network: Each computer has a signal strength equal to its node number. Two computers are connected each second. A network consists of computers that are connected (directly or indirectly). The strength of a network is the highest signal strength among all computers in that network. A single computer forms a network with a strength equal to its own signal strength. After each second, calculate the sum of the strengths of all networks in the system. Examples Example 1 Input c_nodes = 5 c_edges = 4 c_from = [1, 2, 1, 4] c_to = [2, 3, 3, 5] Output [14, 12, 12, 8] Explanation In the ith second, the computers numbered c_from[i] and c_to[i] get connected. Initial state (before any connections): Network 1 = {1}, Strength = 1 Network 2 = {2}, Strength = 2 Network 3 = {3}, Strength = 3 Network 4 = {4}, Strength = 4 Network 5 = {5}, Strength = 5 At the 0th second: computers 1 and 2 get connecte