Company: MediaNet_july
Difficulty: medium
Fire nation's fury I Problem Description In the world where avataar is missing, the fire nation has started a war against all other kingdoms. The fire nation has N cities numbered from 1 to N connected with some roads. Given arrays A and B of size N-1, there is a bidirectional road from A[i] to B[i] and we can reach each city from any other city. We consider city with index 1 (1 based index) as the root city. These cities need to work together in order to conquer the world but they are very egoistic. Each city is associated with some jealousy value. i th city's jealousy value will be equal to number of cities with index > i in its subtree. The Fire Lord gave you a very important task. Find the total sum of all the jealousy values of all the cities. Since the answer can be big, return the output % 1000000007 Constraints 1 <= N <= 10 5 1 <= A[i], B[i] <= N Input Format First argument contains A. Second argument contains B. Output Format Return a single integer as the answer t