Closed PrakharRathore123 closed 2 years ago
@SarthakKeshari Kindly acknowledge this.
Please assign me this i can contribute to it
Please assign me this i can contribute to it
@Abhi-1301 This is a PR. Kindly claim issues. You may refer CONTRIBUTING.md for further details.
Issue Id you have worked upon -
386
Briefly explain your program logic -
1)Initialize the value and weight array 2)If weight of bag is less than equal to zero the return zero 3)If No. of items is less than equal to zero the return zero 4)If weight of last items is more than weight of bag then return for n-1 item 5)Their is two possibility take or not if take it then item are 1 minus and weight is weight minus weight of that item + val of that item else item number is one less
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.
Screenshots(Attach 2 screenshots of your own input and output) -
Attach here
![KNAPSACKB](https://user-images.githubusercontent.com/58821221/136669699-aa9524ee-aa2b-45e7-aaa2-a10a2002542f.PNG)
Checklist:
Eg - If your code follow the below guidelines. Kindly change [] to [x]
All the conditions should be fulfilled for considering your code for merging -
[x] I have mentioned the question as comment in my solution file.
[x] My code follows the guidelines of this project.
[x] I have performed a self-review of my own code.
[x] I have commented my code.
[x] My code gives the correct output.
[x] I confirm that I have not copied the code from anywhere. In case its found that I have copied even after successful merge then I can be banned from the repository and hacktoberfest.
[x] I affirm that I strictly follow contributing guidelines and code of conduct.