Company: Rippling_21stjuly
Difficulty: medium
A server network is represented as a tree of g_nodes servers indexed from 1 to g_nodes , connected by g_nodes - 1 bidirectional links. The i -th link connects the servers g_from[i] and g_to[i] . Transferring data across one link takes exactly 1 unit of time, and data always travels along the unique path between two servers. Find the maximum time needed to transfer data between any two servers of the network. Input format The first line contains two space-separated integers g_nodes and m , where m = g_nodes - 1 is the number of links. Each of the next m lines contains two space-separated integers g_from[i] and g_to[i] . Output format Print a single integer — the maximum transfer time between any pair of servers. Constraints 1 ≤ g_nodes ≤ 2 × 10 5 m = g_nodes - 1 1 ≤ g_from[i], g_to[i] ≤ g_nodes , g_from[i] ≠ g_to[i] The given links always form a tree (the network is connected and has no cycles). Sample Input 5 4 1 5 1 3 1 2 5 4 Sample Output 3 Explanation The