Company: LinkedIn_4th june_on campus _iit guwahti
Difficulty: medium
For a tree with n nodes rooted at node 0 (nodes numbered from 0 to n-1), where each node i has a value given by values[i], determine the maximum sum of values along any path that starts at a node and only goes downward in the tree. Consider only paths of the form u 1 , u 2 , u 3 , ... u k where each node u i is a child of node u i - 1 for 1 < i <= k. For example, given the following tree (labeled node number / value): [image of tree] Two possible paths are 0 → 1 → 2 → 3 which has a sum of 5 + 7 + (-10) + 4 = 6 and 1 → 2 → 3 with a sum of 7 + (-10) + 4 = 1. The highest sum path is 0 → 4 with a sum of 5 + 15 = 20. Function Description Complete the function bestSumDownwardTreePath in the editor with the following parameter(s): int parent[n] : each parent[i] represents the parent node for node i, parent[i] = -1 means node i is the root int values[n] : each values[i] represents the value of node i Return int : the largest sum of values along a path down t