Getting TLE .Please help to debug

code :- https://onlinegdb.com/f00pzAoS6.
please help to remove TLE problem

constraints for M and N are upto 10^5 so using recursion will give you TLE for bigger values of M and N. You need to use dynamic programming approach for this problem to get rid of TLE.

1 Like

Okay. Thank you. :slight_smile:

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.