text: from typing import List
  
  def max_profit_1(prices: List[int]) -> int:
      min_price, max_profit = prices[0], 0
      for price in prices:
          min_price = min(min_price, price)
          profit = price - min_price
          max_profit = max(max_profit, profit)
  
      return max_profit
  
  def max_profit_2(prices: List[int]) -> int:
      ans, dt = 0, 0
      for i in range(0, len(prices) - 1):
          q = prices[i + 1] - prices[i]
          dt = max(dt + q, q)
          ans = max(ans, dt)
      return ans