In this approach, we will find the local minima and maxima. The local minima will be treated as the starting index, and the local maxima will be treated as the ending index. If local minima do not exist, then return. We will also be updating the solution by updating the count of buy-sell pairs.
In this approach, we will find the local minima and maxima. The local minima will be treated as the starting index, and the local maxima will be treated as the ending index. If local minima do not exist, then return. We will also be updating the solution by updating the count of buy-sell pairs.