Target sum pair hint

the algo discussed in this video do not work for input like 2,3,3,2
sorted = 2 ,2,2 ,3 and same pair will be printed for two times.
2 and 3
2 and 3
how can we solve it?
https://online.codingblocks.com/player/28486/content/4682/5944

Hello @mddanish,
To avoid printing the same values again, run the outer loop for i form 0 to n-1 and the inner loop for j from i+1 to n-1. You won’t need to sort the array.

I have tried but getting repeated result. let me walk through.
for 2,3,3,2, sum=5
i=0 , j=1
i.e 2+3 == 5 => print 2,3
i=0, j=2
i.e 2+3 == 5 => print 2,3
i=1, j=3
i.e 3+2 == 5 => print 2,3
so it is repeating. break would not sufficient as same pair is repeating for different i.

@mddanish,
You need not worry about such cases.
The same set of numbers is occuring again, so the output will also repeat. There is nothing wrong in it.

You just have to ensure that the numbers with same indices do not repeat.
Eg: If for i=0 and j=2, numbers are printed, don’t print them again for i=2 and j=0.
Rest is fine.