Solution of this problem

can I get a soon go this problem because I am unable to understand the editorial

here is my solution
you can take this as reference to understand https://ideone.com/SPsXY4

if you have some doubts in this feel free to ask doubt