1128. Number of Equivalent Domino Pairs
On This Page
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