Wrong answer in 2 testcases

https://ide.codingblocks.com/s/58977
https://hack.codingblocks.com/contests/c/511/1604

please help me with this problem

Hey Gaurav, your logic is correct but you are getting wrong answer because your order of output is not correct as you are supposed to print the output in increasing order.

Hey Gaurav, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required