Code giving wrong output for test case 1, please correct the code
Hello @7nishit,
Mistake in your code:
you have defined the dp array with a fixed size of 5002.
But, the column refers to the possible target(or sum) and as per the constraint given in the question.
column can have values greater than 5002.
So, follow the constraint properly.
Hope, this would help.
Give a like if you are satisfied.
I have tried that , but it is giving me either a TLE or segmentation fault. Code -https://ide.codingblocks.com/s/247154
Hello @7nishit,
I have corrected your code:
Refer to comments for better understanding.
Hope, this would help.
Give a like if you are satisfied.
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.