Please give some explanation about the problem
Can't solve the problem
whether to take a 1d dp and 2d dp and also the purpose of N, since I can’t figure out it’s importance
@jayasmit98, the value of N is 10^3 that means you can have an approach having (n^3) cause computer can perform 10^9 operations in a second.
So whatever you have to think you have to think under (n^3) time complexity.
Moreover, if you want to go with dp approach, I would suggest you to first thunk of a brute force.
Hope this will help you in understanding question better 
1 test case is failing
Check for the side cases
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.