DEV Community

Discussion on: Daily Challenge #228 - Best Profit in Single Sale

Collapse
 
vidit1999 profile image
Vidit Sarkar

Here I represented the loss with negative number.

For the last case the vector is sorted in descending order. So there is no way user will make any profit. The minimum loss is 1 (i.e. buy the item at price 5 and sell it at price 4).

Remember you have to buy the item first and then sell it.