Deviopath › JavaScript

0/1 Knapsack

Hard · Dynamic Programming

You have items where item i weighs weights[i] and is worth values[i]. Your bag holds at most capacity total weight.

Write a function knapsack that returns the maximum total value you can carry. Each item can be taken at most once (or not at all).

Next: Edit Distance