Feature #2: TTL Expiry

Implementing the "TTL Expiry" feature for our "Network" project.

Description

To limit the number of messages flooding onto the network, we will set a TTL(Time-to-live) on each message. The number of hops a message will propagate away from the server will not exceed the value of the message’s TTL. In this problem, the server can be at any node in the tree. We want to determine which nodes will successfully receive a message from the server, given a specific TTL value. The network structure is represented by n-ary trees.

We’ll be provided with an n-ary tree network structure, the server device from where the message needs to propagate, and the TTL value for the message. We need to return the nodes after which the TTL value of the message will expire.

Let’s try to understand this better with an illustration:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.