Problem not complete


#1

the question should explicity specify that there is no cycle in the graph otherwise it fails for cases where there is a cycle present


#2

Tree don’t have cycles. And in question its mentioned explicitly “Given an undirected tree”.