MEMORY LIMIT EXCEEDED

how should i optimise the memory complexity of this ??

hello @Shobhit_kumar

try using map …

@Shobhit_kumar
dp solution might also give tle.
refer NLOGN approach from here ->link

sir i have tried using map also but there it is giving tle

yeah dp solution is not working here .check my last reply for NLOGN approach

https://ide.codingblocks.com/s/350643 here is that approach

but sir why is this happening that we need not check for the other cases?? i mean don’t we should check for all the possiblities??

yeah , we need to consider all possibilities.
but by observation they are saying that looking for one valid partition is also working

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.