Max profit trade
easyYou are given a list of daily stock prices, where prices[i] is the price on day i. Return the maximum profit you can make by buying the stock on one day and selling it on a later day.
Exactly one buy and one sell. If no trade makes a profit, return 0.
Input: prices = [31, 18, 24, 12, 20, 45, 27]Output: 33 // buy on day 3 at 12, sell on day 5 at 45
Input: prices = [40, 33, 27, 19, 12]Output: 0 // prices only fall, so no trade is worth making
State the run time and the extra memory your solution uses.