The linked list ends up not being correct.
Hello @Christopher_Jon_Perr,
I tested the provided solution on several inputs and the returned outputs are as expected. For instance, the solution returns 2 28 4 14 6 12 8 10
for the input 2 4 6 8 10 12 14 28
, 2 100 4 88 6 28 8 14 10 12
for the input 2 4 6 8 10 12 14 28 88 100
, 2 8 4 6
for the input 2 4 6 8
, and 2 6 4
for the input 2 4 6
. All of these are correct and expected outputs.
Hope this helps!
It creates a cycle in the resulting list.