input: from typing import List, Tuple
  
  def knapSack(W: int, wt: List[int], val: List[int], n: int) -> int:
      """
      Find the optimal solution to solve a knapsack problem using dynamic programming.
      Given a knapsack capacity W and a list of items with their values and weights,
      return the maximum value that can be put in the knapsack.
  
      >>> knapSack(50, [10, 20, 30], [60, 100, 120], 3)
      220
      """
output:     dp = [0] * (W + 1)
      for i in range(n):
          for w in range(W, wt[i] - 1, -1):
              dp[w] = max(dp[w], dp[w - wt[i]] + val[i])
      return dp[W]