Not able to understand how to solve even from editorial

Hi Team,

I am not able to understand how to solve this problem,even looking from solution.

Please give some other solution/explain it to me.

Thanks

How much time will TA’s taketo respond?

PLease assign multiple TA’s to take doubts and not one

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.

Please give a solution to This problem. Please assign a new TA

Still unresolved…

@kavit I think I gave you the reason for the unfortunate glitch to your doubts in the doubts panel bcoz of which your doubts was not resolved.
but you can refer this video for your doubt :
This video is in C++ but I am telling you to refer only the approach not the code bcoz if you follow the approach code is easy to write.

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.