Target sum pairs

https://ide.codingblocks.com/s/35167
https://hack.codingblocks.com/contests/c/52/211

Only half of the test-cases are working.

I am also facing the same problem

For the input
5
4
3
1
2
5
5

Your code gives output
4 and 1
3 and 2

But the required output is
1 and 4
2 and 3

So sort the array before calling the function.
Then you’ll get the output in increasing order as required.
Your logic is correct