Timelimit problem what i have to change in my code to get the test case passed

Hey @Rajat-Sharma-2078329489142103 you are are solving the same sub-problem multiple times resulting in a TLE. Instead try solving it with a bottom up dynamic programming approach. If you have trouble figuring out the dp approach please feel free to ask.