Wrong 'fastest' solution and weak test cases


#1

The fastest solution given is wrong and yet the test cases fail to recognize that.

Consider this input: 15 1 2 4 3 -1 5 -1 -1 -1 6 -1 -1 -1
The correct output should be: 1 2 3 6


#2

It’s because ‘prev’ remembers only the last node not the nodes before