Given an array prices where prices[i] is the price of a given stock on the i-th day, find the maximum profit you can achieve by buying on one day and selling on a later day.
If no profit is possible, return 0.
Example:
Input:
7,1,5,3,6,4
Output:
5
Reasoning:
We start by initializing the minimum price and maximum profit: min_price=7, max_profit=0.
We then iterate through the array, updating min_price and max_profit as we find lower prices and higher profits: