Company: Bolt.earth
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 i connects two vertices, a_i and b_i. 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 The function signature is: vector<long long> solve (int N, string Color, vector<vector<int>> Edges) Input format for custom testing Note: Use this input format if you are testing a