<prompt> Unapewa safu ya bei ambapo beii ni bei ya hisa fulani siku ya i_th. Unataka kuongeza faida yako kwa kuchagua siku moja ya kununua hisa moja na kuchagua siku tofauti katika siku zijazo kuuza hisa hiyo. Rudi faida kubwa unayoweza kufikia kutoka kwa shughuli hii. Ikiwa huwezi kupata faida yoyote, rudi 0.  <response>: To solve this problem, you can keep track of the minimum price seen so far and the maximum profit that can be made by selling at the current price. You iterate through the array and update the minimum price and maximum profit as you go along. Finally, return the maximum profit.Heres the code:def maxProfitprices: if not prices: return 0 min_price prices0 max_profit 0 for price in prices: if price min_price: min_price price else: profit price - min_price if profit max_profit: max_profit profit return max_profitExample usage:printmaxProfit7,1,5,3,6,4 Expected output: 5 buy on day 2 at price 1 and sell on day 5 at price 6printmaxProfit7,6,4,3,1 Expected output: 0 cannot make a profit 