Radio Waves

Problem Overview

  • Find the longest distance between two devices that can communicate along a simple path where adjacent devices’ frequencies differ by at most 1.
  • Input: a tree with network_nodes, edges via network_from/network_to, and frequency values in {1,2,3}; Output: the max path length, or 0 if none.
  • Distance is the number of edges; paths are simple (no repeated nodes); other constraints not specified.
  • Real-world context: compatibility in a radio-wave device network.
  • A Snowflake interviews coding interview problem and practical interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: