programming
programming copied to clipboard
Gives a solution to the problem of Peaks and Valleys in C++
Buying and selling stocks gets optimized for maximum profit.
The key point is we need to consider every peak immediately following a valley to maximize the profit. In case we skip one of the peaks (trying to obtain more profit), we will end up losing the profit over one of the transactions leading to an overall lesser profit. #HacktoberFest