Tilling problem - ii

Where am I doing wrong?

Please paste your code on ide.codingblocks.com and after saving, send the link generated.

Can you please clear my doubt?

You code will give TLE as per constraints N and number of test-cases are large.
All you have to do is just add memoization to your code.