I have done above code by myself it is passing only one test case


It is passing only one test case and is showing TLE in other test cases.

Hey @priya_Jain the reason why you got TLE is that you are not using DP array for this problem. Prateek bhaiya has shows you how can you compute or think about this problem , but as for test cases . Two DP array will be needed and for that you can have a look at your course video in DP section. You will find same problem discussed by DP approach and when you will use that approach you will get your test cases passed. Happy to help :smile:
Keep learning & growing @priya_Jain