Algorithms, Leetcode, Datastrucutre, Java.
(dp[i][j] != dp[i - 1][j]) { selectedItems.add(items.get(i - 1)); j -= items.get(i - 1).weight; } i--; } return selectedItems; } public static void main(String[] args) { List<Item> items = new ArrayList<>(); items.add(new Item(2, 12)); items.add(new Item(1, 10)); items.add(new Item(3, 20));