Company: Adobe_13_dec
Difficulty: medium
Minimum Sum Problem Description You are given a tree (a connected, undirected graph with no cycles) consisting of n nodes numbered from 0 to n-1 and also an array weight of length n such that weight[i] represents the weight of i th node. You are also given a 2D integer array edges where edges[i]=[x,y] means there exists an undirected edge between x and y . For each pair (i,j) of nodes, you have to sum the weight of the node with the minimum value that occurs in the simple path between i and j . For example, from node 1 to node 5, there exists a node with weight 2 in the path between node 1 and node 5, and this weight is minimum. So, we have to add this value to our result. Finally, we sum the minimum weights of nodes that occur in the path for each pair of nodes and return that value. Note Nodes are numbered from 0 to n-1 . A path and its reverse are considered the same (the path from i th node to j th node is the same as the path from j th node to i th node, so we need to consider it