Time limit exceeded

i have arrived at the brute force solution but 4 out of 5 test cases are TLE. can you tell me any other approach that might work

Hello @akshatsaraswat03,

You will face TLE with recursion.
Dynamic Programming is the solution for thi problem.
Suggestion:
Solve this after completing DP.

Hope, this would help.
Give a like if you are satisfied.