You are viewing a single comment's thread. Return to all comments →
It's a tree but with nodes that have duplicate data.
In this case, swapNodes won't change the nature of the tree.
it is not mentioned in the problem.....or in the input conditions........
There is no data (well, you could say node's own index is its payload). It's just a bunch of indexes. So the root has node number 2 as a left child and also a right child. And node number three has itself as a right child.
Not a tree. Somebody just doesn't understand the format. Which really isn't surprising given the poor description.
But if anyone wants it blow by blow: