Wrong output, coming out to be - infinity

hi @pranaynigam
no need to create 2d dp array… u can do it in 1d only… refer this https://ide.codingblocks.com/s/622797

Yeah your method is working fine. Now im getting the correct output but test cases are not passing

try for this input
5 10
-1 33 -1 176 -1 46 -1 120 -1 300

expected o/p - 112

but in the constarints value is given to be positive

yes… but -1 to aahi skta hai na… read the ques carefully…

yeah my ans is coming out wrong. I understood your 1D array approach. Please edit my 2D array code as i want to find the mistake in this approach

hi… just apply concept of unbounded knapsack… it should work fine…

i have applied the same concept and the sample test case output is also correct but the test cases are not passing

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.