IBM Interview Question

Leetcode medium-hard question, one of them was a knapsack problem.