Dunzo Interview experience

Given an undirected tree of N vertices. Each vertex is either RED or BLUE or UNCOLORED. It is guaranteed that the tree contains at least 1 RED and 1 BLUE vertex.
“happy“
Choose an edge and remove it from the tree. Tree falls apart into 2 connected components. How many such edges are present such that neither of the resulting components contain vertices of both RED and BLUE colors.

 R
/   \
R     C
	   \
	    B
	   

Removing edge between R--- C and C---- B also satifies the condition
Output = 2

I did not clear this round but if someone can help with the solution will be of great help

Comments (3)