You immediate problem is
You have to change it to
while(i < (sequence.size() - 1) )
However that's not enough.
First of all you have to replace
in comparisons (because it should be a strictly
increasing sequence), then you shoud try to remove either
, accepting the first one that preserves locally the incresing
property. Lastly 'you can work on points of style
' e.g. return
instead of waiting the end of the loop.