Grouped Knapsack Problem: 2D and 1D Dynamic Programming Approaches

Problem Statement Given n items, each with weight weight[i], value value[i], and group index group[i], pack them in to a knapsack with maximum capacity W. Each group can contain at most one item. Find the maximum total value. Solution 1: Two-Dimensional DP Array This is a classic grouped knapsack problem. First, we need to process all items sim ...

Posted on Wed, 20 May 2026 05:18:47 +0000 by jeffshead