Tle and wrong test case

I have solved using top down dp but it’s showing tle and weong answer.

hello @mkg825412gir

the dp solution will show tle becuase it has time complexity of cubic order O(n^3).

try to solve it in O(NLOGN) .
pls refer this hints ->link

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.