input: Write a python function to solve the knapsack problem.
  assert knapsack([10, 20, 30], [60, 100, 120], 3, 50) == 220
  assert knapsack([1, 3, 4, 5], [1, 4, 5, 7], 4, 7) == 9
  assert knapsack([1, 2, 3], [10, 15, 40], 3, 6) == 65
output: def knapsack(weights, values, n, W):
      dp = [[0 for _ in range(W + 1)] for _ in range(n + 1)]
      
      for i in range(1, n + 1):
          for w in range(1, W + 1):
              if weights[i-1] <= w:
                  dp[i][w] = max(values[i-1] + dp[i-1][w - weights[i-1]], dp[i-1][w])
              else:
                  dp[i][w] = dp[i-1][w]
      
      return dp[n][W]