1512. Number of Good Pairs

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1512

class Solution:
    def numIdenticalPairs(self, nums: List[int]) -> int:
        cnt = Counter(nums)
        return sum(v * (v - 1) for v in cnt.values()) >> 1