I have been trying to solve this question
And my approach is
But it gives a TLE verdict. Can anyone please suggest me an optimised solution for the same, as i cant understand the editorial thats mentioned with the problem.
Thanks.
I have been trying to solve this question
And my approach is
But it gives a TLE verdict. Can anyone please suggest me an optimised solution for the same, as i cant understand the editorial thats mentioned with the problem.
Thanks.