Please Explain the logic for this problem

Here’s the working code : https://www.codechef.com/viewsolution/13726415

You did not take no of test cases into consideration, and few other things like that filldp() function were not needed (although not incorrect)

1 Like

Thanks a lot…Happy Coding