I even checked the GFG code and am getting the same answer as that. I even c]pasted the GFG code entirely still not getting the correct answer
What is wrong with my code?
Can you share C++ code?
I have already shared the code. Itsn in c++ only
You have to remove the unavailable items before constructing dp array.
I have already added condition for removing -1. Also the code that i copied from gfg already removed -1. Still it did not work. Can you send me some test cases? None are working for me but sample input runs correctly.
if you dont remove it early on, then it is possible that i-1 that dp[i][j] try to acess would be -1 and this would give wrong answer so it is important to remove all of -1 early on and construct dp array only using positive numbers.
Input was wrong
Corrected