Company: Nokia_23march
Difficulty: medium
Hero's Journey in a Tree Problem Description You are given a tree with n nodes (1 to n ) rooted at node 1 and n-1 edges. Each edge contains a monster with power p . A hero lands on a node u with initial health H and tries to climb toward the root. He battles every monster along his way. You can determine the battle condition in the following way: If H < p , the hero stops at the current node. If H > p , the hero defeats the monster, loses p health, and moves to the parent node. If H = p , the hero defeats the monster, loses all his health (H becomes 0), ascends to the parent node, but dies on arrival. Your task is to determine the highest node (closest to the root) the hero can reach for each query. Complete the function solve provided in the editor. This function takes the following parameters and returns the required answer: n : The number of nodes in the tree. edges : A list of lists of the form (u, v, p) , where u and v are connected nodes, and p is the monster's power on tha