Idea is important. The idea for this problem is just to buy when the price is about to increase, and to sell when the price is about to fall (Since there is no tranaction fee;)
One thing to take note: the vector.size() function returns an unsigned function. and unsigned 0 - 1 = Large Number. (Because it overflows). Therefore the for loop would be entered, and it would cause RunTime Error (because trying to access empty prices vector).
Therefore, one need to check the size of the price vector first.