Output doesnt comes in desired order

The code I wrote seems perfectly fine and even it shows correct outputs but it doesn’t prints the outputs in desired order.
I dont need new code just please rectify the mistakes in my already prepared code

hi @sinchan1509_1a917d7b6cc3cbb9,
just sort the array but then you’ll get TLE as it will be o(n3) for 1 test case and also the code is not optimal

so use 2 pointer approach
you can refer here : https://ide.codingblocks.com/s/659083

ok thanks i got it thanks for the help

1 Like

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.