Let us say if we have input 1 1 1 1 and target is 2.Then the number of pairs that form the answer is 6.Therefor it should print “1 and 1” 6 times,but according to this algorithim it will print only 3 times.
Wouldn't it give wrong answer in case of duplicates
@sushant19_99 Yes you are right. But actually the question should be to print only the unique pairs (without duplicates). For such a case, the approach explained will work.