Company: Deutsche_Bank
Difficulty: medium
Black and white tree Problem Description Given a tree with N vertices labeled from 1 to N, rooted at vertex 1. The tree is an undirected graph with N-1 edges. Each edge connects two vertices, a, and b. Each vertex i is colored either white (represented by '0') or black (represented by '1'). The beauty of a vertex i is the number of paths in its subtree that have end vertices of the opposite color. Find the beauty of all N vertices. Note A subtree of a vertex i is a connected sub-graph consisting of all the descendants of i, including i. Function description Complete the function solve. This function takes the following 3 parameters: N: Represents the number of vertices Color: Represents the color of the vertices Edges: Represents the elements denoting the edge connecting two vertices Input format for custom testing Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code. The first line contains a single i