Hi! Where is the problem statement? Clicking on [LEADGAME] takes me to this discussion page.
Please check o/p of the above recursion. I believe its correct. I can post my memoized version where answer for only the last couple test cases is differing in sometime.
Keshav, thanks for taking time to run the code. I find this very strange because if check out the exact same non memoized version which is giving the right outputs Online C++0x Compiler & Debugging Tool I only momized this and nothing else. Why do you think the answers differ? Also I am pretty sure I was getting wrong answer only for last couple of tests. I will probably check with the code I wrote once again if there are issues. Appreciate your help.
Thanks for the reply Keshav. I understand your point. Nevertheless, why is the memoization making a difference anyway. I just remove all dp[i][j] and keep it just recursive, it works for the sample cases at least. If I add dp[i][j], it makes a difference for the last couple test cases. This is what's confusing me a bit.