Code seems perfect to me but its showing time limit exceede

Please help me in rectifying my code but telling me in which part of code I am doing error.

here is my code

hi @sinchan1509_1a917d7b6cc3cbb9
Refer this–>

@sinchan1509_1a917d7b6cc3cbb9
Is there anything else???

Wait actually I slept last night, just saw your code I will try to understand it and then will let you know

In the meanwhile can you please let me know what was wrong with my code.

Okay np… take your time…

Please let me know whats wrong with my code

complexity is high, and according to constraints set for this ques, we have to use a optimal approach… brute force don’t work everywhere…

Thank you so much I was able to get success

1 Like

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.