Two pointer approach seems very good in this scenario.
But what if array elements are not unique and repetition of element is possible.
How would be calculate count of pairs with sum k.
suppose array is 2,2,2,2 and we are to find number of pairs having sum equal to 4.
Clearly answer is 6.
What is the efficient way to solve it.