1512. Number of Good Pairs

Updated: 2024-03-12
1 min read
[]

On This Page

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