This is my solution
i am not able to understand the solution given in the editorial
Hey @tAkshat can you please elaborate where are you getting troubled at?
If you want code for reference, you can have it here https://ide.codingblocks.com/s/329221 This might help