the question should explicity specify that there is no cycle in the graph otherwise it fails for cases where there is a cycle present
Problem not complete
Tree don’t have cycles. And in question its mentioned explicitly “Given an undirected tree”.
the question should explicity specify that there is no cycle in the graph otherwise it fails for cases where there is a cycle present
Tree don’t have cycles. And in question its mentioned explicitly “Given an undirected tree”.