Company: Deutsche_Bank

Difficulty: medium

Problem Statement

Problem Description You have a rooted tree of N vertices, labeled 1 through N and rooted at vertex 1, formed as an undirected graph with N-1 edges where each edge links two vertices a and b. Every vertex i is painted either white (shown as '0') or black (shown as '1'). Define the beauty of a vertex i as how many paths inside its subtree connect two endpoints of opposite colors. Report the beauty for every one of the N vertices. Note The subtree of a vertex i consists of i together with every one of its descendants, forming a connected subgraph. 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

More Deutsche_Bank OA questionsInterview experiences