Closed PrakharRathore123 closed 2 years ago
@SarthakKeshari Kindly issue me this problem
@SarthakKeshari Kindly issue me this problem
@PrakharRathore123, Kindly add test cases to it. With input, output and explaination
@SarthakKeshari Kindly check the test cases
@PrakharRathore123, Kindly add your solution to "Dynamic Programming" folder. Deadline - 10/10/2021
Enter your question -
Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. In other words, given two integer arrays val and wt which represent values and weights associated with n items respectively. Also given an integer W which represents knapsack capacity, find out the maximum value subset of val such that sum of the weights of this subset is smaller than or equal to W.
Test Case
Example 1)- weight array is given {15,30,40} value array is given {60,100,150} Maximum weight capacity is given = 45 so we have to input the items such the values is maximum without exceeding the weight capacity of bag. so in this the maximum value is 60+100=160 weight occcupied is 45 that doesn't exceed the Maximum weight capacity.
Example 2)- weight array is given {15,30,45} value array is given {60,100,200} Maximum weight capacity is given = 45 so we have to input the items such the values is maximum without exceeding the weight capacity of bag. so in this the maximum value is 200 weight occcupied is 45 that doesn't exceed the Maximum weight capacity.
Enter link to the question(if question belongs to any online platform) -
-
Tags for the question(eg - Array, Basic, Stack, etc.) -
Recursion , Dynamic programming ,optimization,Array