You are given an integer array prices where prices[i] is the price of a stock on day i.
You may complete at most one transaction: choose a day to buy one share and a later day to sell that share.
Return the maximum profit you can achieve. If no profit is possible, return 0.
prices
: array of integers, length
n
1 <= n <= 2 * 10^5
0 <= prices[i] <= 10^9
prices = [7,1,5,3,6,4]
5
(buy at
1
, sell at
6
)