Your question is Maximize Profit from Stock Prices. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given an array of integers prices where prices[i] is the price of a given stock on the i-th day, return the maximum profit you can achieve from this transaction. You may complete at most one transaction (i.e., buy one and sell one share of the stock). If you cannot achieve any profit, return 0.
def max_profit(prices: list[int]) -> int: