Count equal pairs

Write codeEasy13 min

Your task

Given a list of integers nums, count the number of unordered pairs of positions (i, j) with i < j whose values are equal. For example [1, 1, 1] has 3 such pairs and [1, 2, 1] has 1. Return the total count. The list may be empty (return 0).

Examples

count_equal_pairs(nums: list[int]) -> int
Example 1
Inputcount_equal_pairs([1, 1, 1])
Output3