Company: GoComet_11march
Difficulty: medium
Radio Waves Problem Description A network of network_nodes radio devices, numbered 1 to network_nodes , is connected as a tree: there are exactly network_nodes - 1 undirected links, and the i -th link joins devices network_from[i] and network_to[i] . Every device transmits on an integer frequency of 1 , 2 or 3 units; frequency[j] is the frequency of device j + 1 . Two devices joined by a link can talk to each other directly only when the absolute difference of their frequencies is at most 1 . A device can send a message to another device when the simple path between them uses only such links, that is, every pair of consecutive devices on the path has a frequency difference of at most 1 . The distance between two devices is the number of links on the simple path between them. Find the largest distance between two distinct devices that can send messages to each other. If no two distinct devices can send messages to each other, the answer is 0 . Complete the function calculateMax(network_