input: Write a function to calculate the maximum revenue from buying and selling a stock given an array of stock prices. The function should return the maximum possible difference between the highest price and the lowest price that can be achieved in a single transaction.
  
  def max_revenue(prices):
      diff = [prices[i + 1] - prices[i] for i in range(len(prices) - 1)] 
      max_diff = 0
      for i in range(len(diff)): 
          for j in range(i + 1, len(diff) + 1): 
              current_diff = sum(diff[i:j]) 
              if current_diff > max_diff: 
                  max_diff = current_diff 
   
      return max_diff
  
  assert max_revenue([10, 7, 5, 8, 11, 9]) == 6
  assert max_revenue([7, 1, 5, 3, 6, 4]) == 5
  assert max_revenue([1, 2, 3, 4, 5, 6]) == 5
  assert max_revenue([7, 6, 4, 3, 1]) == 0
  assert max_revenue([]) == 0
output: def max_revenue(prices):
      if not prices:
          return 0
      min_price = prices[0]
      max_diff = 0
      for price in prices:
          if price < min_price:
              min_price = price
          elif price - min_price > max_diff:
              max_diff = price - min_price
      return max_diff