input: Write a function to calculate the maximum possible revenue from the items with given weights and values. The function should return the maximum value that can be obtained with a knapsack of capacity W. If the list of weights or values is empty, the function should return 0.
  
  assert knapsack([2, 1, 3], [4, 2, 3], 3)==7
  assert knapsack([1, 2, 3], [6, 10, 12], 3)==22
  assert knapsack([1, 1, 1], [10, 20, 30], 3)==60
  assert knapsack([], [], 0)==0
  assert knapsack([5, 4, 6], [10, 40, 30], 3)==90
output: def knapsack(weights, values, W):
      if not weights or not values:
          return 0
      n = len(weights)
      dp = [0] * (W + 1)
      for i in range(n):
          for w in range(W, weights[i] - 1, -1):
              dp[w] = max(dp[w], dp[w - weights[i]] + values[i])
      return dp[W]