why is this code failing test cases
??
why is this code failing test cases
??
If you read the problem statement carefully then you will realise that the N value given in input does not represent the size of the array. Infact it is quite useless.
This is a 1D DP problem. The size of the array is W only , not N.
sir but in hint video it is said that this is 0/1 knapsack problem
0/1 knapsack can also be reduced to 1d DP
sir but if i try to implement like knapsack then whats wrong in my code??? why is my code failing test cases??
Size of the array is W which u are inputtng
So re read the question line by line
hello @tejasddongare i have modified your code completely .
if you don’t understand anything please ask here i will answer .
Happy Learning !!
but sir even after replacing now array with weight its failing 2 test cases why???
tushar sir thanks alot