Happay interview question

Dsa question based on graph and trees