TLE comes in this question need optimized appraoch

i am not able to find the more efficient appraoch to this question

@ramanrs1410_c525aa5570d2313c you need to learn SOE approach for this question. This approach will be taught later in the course else you can visit this link to see how it works :

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.