Google 1st Interview Round
Given you are an undirected acyclic graph having maximum number of neighbors = 3. Now you have to return the root vertex of a valid binary tree.
Follow up of Question 1:Given you are an undirected acyclic graph having maximum number of neighbours = 3. The vertices are colored black and white. You are given adjacency list and array of colors.Now you have to return the root vertex of a valid binary tree that has alternating colors at levels. (B- W-B-W... or W-B-W-B...)if possible otherwise return -1.
Follow up of Question 2:Given you are an undirected acyclic graph having maximum number of neighbours = 3. The vertices are colored Red, Black and White.You are given adjacency list and array of colors. Now you have to return the root vertex of a valid binary tree having alternating colors in order.(R- B - W - R - B- W or B - W - R - B- W- R or W - R - B- W- R- B. Note: BRW is not valid) if possible otherwise return -1.