Maximum Time Taken to Transfer Data
A server network is represented as a tree of g_nodes servers indexed from 1 to g_nodes and g_nodes - 1 edges where the ith edges connect the servers g_from[i] and g_to[i]. The transfer time between any two connected servers is 1 unit.
Given the graph g, find the maximum time taken to transfer the data between any two servers in the system.
Complete the function maximumTimeTakenToTransferData in the editor.
maximumTimeTakenToTransferData has the following parameters:
- 1.
int g_nodes: the number of nodes - 2.
int[] g_from: an array of integers representing the start nodes - 3.
int[] g_to: an array of integers representing the end nodes
Returns
int: the maximum time taken to transfer data between any two servers
1Example 1
The maximum time is required to transfer data from 1 to 3 that takes 2 units of time. Hence, the answer is 2.