1128. Number of Equivalent Domino Pairs

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

On This Page

LeetCode problem 1128

class Solution:
    def numEquivDominoPairs(self, dominoes: List[List[int]]) -> int:
        cnt = Counter()
        res = 0
        for a, b in dominoes:
            x = a * 10 + b if a < b else b * 10 + a
            res += cnt[x]
            cnt[x] += 1
        return res