Can we still get a O(n) solution with O(1) space if the input contains 0?
Currently, the problem states all the inputs are positive. And solutions are based on the idea to enumerate the 3 cross situations. While, if the input contains 0, i.e.,
1, 0, 1... there is a cross.
If 0 is used to signify direction change, one direction change will result in cross (if a positive number follows,) two consecuitive 0s is equivalent to a negative number (if a positive number follows.) The negative number question was already answered.
Negative Number Question