as my original post said, we can even compute the current local maxgain and
try to update global maxgain only when we get a new stock[i] < stock[current
_buyTime], this needs a dummy node at the end of stock[], otherwise we will
fail at [2, 3, 4, 5, 1, 2,3,4, 8] .
in this case [2, 3, 4, 5, 1, 2, 3 ,4, 8, -1(dummy node)],
we init with maxgain as 0, best_buy/best_sell as 0,
and current_buy/current_sell as 0,
then we move on starting from stock[1], only update current_sell again and
again since each stock[i] is greater than stock[current_sell], once we see
stock[i=4]==1 , 1 is smaller than stock[current_buy==0]==2, we know a new
local maxgain is coming, so we compute currently scanned local maxgain as
stock[current_sell]-stock[current_buy] = stock[3]-stock[0] = 5 -2 =3
and update global maxgain as 3, and remembers best_*,
then reset current_sell/current_buy to i=4,continue the loop, update current
_sell as we move along, when we reach -1, we compute local maxgain again and
get local maxgain as 8 - 1 =7, then update global maxgain again.