Company: ethos life_9oct
Difficulty: medium
Track Command Position Problem Description A network contains n nodes, where node 1 is the root node. The network structure is represented as a tree, with each node (except the root) having exactly one parent specified by the array par , where par[i] represents the parent of node i (1-based indexing). Commands propagate through the network as follows: A node sends the command to its direct child nodes in ascending order of their indices. Each child node propagates the command to its subtree using the same process. The propagation stops when all nodes in the subtree have received the command. Given q queries, each query (startNode[i], index[i]) asks for the index[i] th node in the sequence of command propagation starting from node startNode[i] . Return the index[i] th node or -1 if fewer than index[i] nodes receive the command. Each query is processed independently. Examples Example 1: n = 9 par = [-1, 1, 1, 3, 5, 3, 5, 7] q = 4 query = [[1, 5], [7, 2], [9, 2], [3, 6]] Explanation: The