[
math
counter
]
BinarySearch 0918 Equivalent Pairs
Problem statement
https://binarysearch.com/problems/Equivalent-Pairs/
Solution
Calculate frequencies of values.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def solve(self, nums):
ans = 0
for x in Counter(nums).values():
ans += (x - 1) * x//2
return ans