# Problem is wrong. Check is test case, it is obviously not a tree even after the edge is deleted.

• The test cases obviously don't follow the problem statement.

check this, is this really a tree even after the [4,3] is deleted?
Request to remove the point of this problem from contest.
@contributors

• Came here to say that I have the same doubt.

• Absolutely! This is insane.

• After deleting [4,3] it is a tree. What makes you think it isn't?

(Edit: It would be a tree if the problem didn't say "child" but "neighbor")

• @StefanPochmann Because 3 is the child of 5 and it is also the child of 1. This is not a tree.

• @苟利国家生死以

I agree with you.

I got Input: [[2,3],[5,2],[1,5],[4,2],[4,1]] Output: [4,2] Expected: [4,1]

obviously it is wrong.

• @StefanPochmann
The node 3 has two parents, thus 5 and 1. Is this a tree?

• I had the same problem! But apparently, "tree" can also mean just "acyclic connected graph", and the kind of graph that has only one parent per node (which is what I've always called a tree!) is actually a "rooted tree" (https://en.wikipedia.org/wiki/Tree_(graph_theory)#Rooted_tree)

• @shell32 Ah, ok. I hadn't noticed it said "child". So I thought it's just a tree, not a rooted tree.

• This test case is ok, because 3 and 4 are pointing to each other, but there are many wrong testcase. I guess the problem wants us to detect a cycle.

But anyway the statement is not really talking about a tree, but a undirected graph without cycle I think.

• @jiayi.zhang1993
The definition is asking a tree with parents, childs well defined.

But it turned out to be remove an edge in an undirected graph to make it a tree.

All the accepted answers are wrong technically.

• All the accepted answers are wrong technically.

Can you show a valid test case which they fail?

• @StefanPochmann I think if this is not a rooted tree, there are no conceptions of "child" and "parent".

• @StefanPochmann

I used brute force and quite confident about the correctness.
The test case: [[5,2],[3,4],[4,3],[5,3],[1,3]]

My result provide null because there is no solution.
But the expected answer is [4,3], which leaves node 3 still has two parent.

• @jiayi.zhang1993

I understand what you mean, but it is really confusing because the problem has explicitly draw two edges between 1 and 3 in the second example.

• @realhly88 That's not a valid test case, though, since the problem tells us that we can do it, that there is an answer.

• @jiayi.zhang1993 it is exactly the point, the test cases assume an undirected graph which would require union find set, but the problem description assumes directed graph which would require topological sort... and I wasted half an hour programming the latter...

• @StefanPochmann what if child node means not a 'direct child node', just 'one of child node in it's subtree' ?

• @jiayi.zhang1993 Absolutely, but the problem statement says [a,b] means b is the child of a, which is confusing

• @StefanPochmann what if child node means not a 'direct child node', just 'one of child node in it's subtree' ?

That's not a "child" but a "descendant":
https://en.wikipedia.org/wiki/Tree_(data_structure)#Terminology_used_in_trees

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.