Does any one feel that the first test case given is not current.
[3,3,5,0,0,3,1,4]Buy at Index 0 - Price: 3 -> I think Buy order can be placed at Index 1 as well.
Sell at Index 2 - Price: 5
Buy at Index 3 - Price: 0
Sell at Index 5 - Price: 3
Buy at Index 6 - Price: 1
Sell at Index 7 - Price: 4
There is a ambiguity i feel. In the second test, there is a Buy for the 0th index.
Is there something i am misinterpreting.