input: Write a function to calculate the maximum revenue that can be obtained by buying and selling stocks over a period of time given an array of prices. The function should return the maximum difference between buying on a certain day and selling on a later day. If the given array is empty then return 0.
  assert max_revenue([10, 7, 5, 8, 11, 9]) == 6
  assert max_revenue([1, 2, 3, 4, 5]) == 4
  assert max_revenue([7, 6, 4, 3, 1]) == 0
  assert max_revenue([100, 180, 260, 310, 40, 535, 695]) == 655
  assert max_revenue([]) == 0
output: def max_revenue(prices):
      if not prices:
          return 0
      min_price = prices[0]
      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