Number of Good Pairs
A pair of positions (i, j) in the list nums with i < j is good if nums[i] == nums[j]. Return how many good pairs there are.
Example 1
nums [1,2,3,1,1,3]
returns 4
Pairs (0,3), (0,4), (3,4), (2,5): 4.
Example 2
nums [1,2,3]
returns 0
No equal values.
Constraints
1 <= len(nums) <= 500 <= nums[i] <= 20
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.