TLE Error bottom up dp

Two test cases are giving time limit error

Hey @hemantomer1, show me your code so that I can tell you your mistake .

Hey @hemantomer1 can you tell me which test case number you are failing?

test case 1 and 2…

Hey @hemantomer1 you are getting tle i.e., cause of your implementation. I would suggest you to give it a try and change your implementation. If it still gives you TLE, i would provide you with my code :smile:

Hint: bool dp[1001][100001]={0};

declare your dp matrix globally the dynamic declaration of the dp matrix is causing the program to give runtime error as it is not able to create such large amount of memory(contigious) at runtime .

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.