1128. Number of Equivalent Domino Pairs

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

Содержание

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