IDK THE APPROACH

can i get the code of it

You can check the editorial if you just want the code. But if you have any problem in understanding the code or logic we can help.