Algorithms, Leetcode, Datastrucutre, Java.
knapsack(int W, List<Item> items) { int n = items.size(); int maxVal = 0; int maxWeight = 0; List<Item> result = new ArrayList<>(); for (int i = 0; i < (1 << n); i++) { int totalWeight = 0; int totalValue = 0; List<Item> currentItems = new ArrayList<>(); for (int j = 0; j < n; j++) { if ((i & (1 <<