input: Write a function to find the maximum profit from stock prices.
  assert max_profit([8, 12, 4, 5, 7, 10, 9]) == 6
  assert max_profit([7, 1, 5, 3, 6, 4]) == 5
  assert max_profit([7, 6, 4, 3, 1]) == 0
output: def max_profit(prices):
      if not prices:
          return 0
  
      min_price = float('inf')
      max_profit = 0
  
      for price in prices:
          if price < min_price:
              min_price = price
          elif price - min_price > max_profit:
              max_profit = price - min_price
  
      return max_profit