Support we take 5 and 7

So here the answer would be 1

but interviewbit is giving 2 as answer.

Another example:

2,3,6 = output should be 4 but interviewbit is saying 8

Why is that.

Support we take 5 and 7

So here the answer would be 1

but interviewbit is giving 2 as answer.

Another example:

2,3,6 = output should be 4 but interviewbit is saying 8

Why is that.

Its actually correct

The question says we have to cosider all pairs

So in 5 7 the answer is 2 because (5,7) and (7,5) are different

Similarly every pair occurs twice hence the final answer is doubled.

(5,7) and (7,5) are not different, problem statement is wrong

[1,2,3] now tell me how many pairs are there?

{ (1,1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3) } we will have a total of these 9 pairs.