Radio Waves

Asked at Snowflake · Coding & Leetcode-style Questions · Difficulty: Medium

There is network of radio-wave devices which can transmit waves of integer frequencies of 1, 2 or 3 units. Two devices can receive messages directly if their transmission frequencies have an absolute difference of 1, at most. The network is given by a tree having `network_nodes` number of devices and `network_nodes - 1` number of edges. The edges are numbered from 1 to `network_nodes`, in the form of two arrays, `network_from`, and `network_to` respectively. There is an undirected edge from `network_from[i]` to `network_to[i]` (`1 ≤ i < network_nodes`).

Loading the problem…