values. Count the index pairs (i, j) with i < j and values[i] == values[j].values=[4, 9, 4, 4, 9] → 4
The three 4s give three pairs and the two 9s give one more, 4 in total.
values=[2, 5, 8] → 0
All values differ, so there are no pairs.
values=[6] → 0
values=[4, 9, 4, 4, 9]
4
Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.