In this problem, an example test case is as follows:

But I did some experimenting, and this tree would yield the same results:

Why is the one they give correct and the one I give wrong?

In this problem, an example test case is as follows:

But I did some experimenting, and this tree would yield the same results:

Why is the one they give correct and the one I give wrong?

Bump.

The second line of the input is the bfs, and the third line is the dfs. It looks like you swapped the two.

Ok, but even then, this graph would work:

So what makes

In the problem statement they say “generate the edge list of **a** simple, undirected, connected graph corresponding to these orders,” not **the** graph so I imagine if there are multiple solutions you are allowed to return the edge list corresponding to any one of them.

Yeah, you were right.