1227. Number of Equivalent Domino Pairs
My accepted Python solution to LeetCode problem 1227, Number of Equivalent Domino Pairs, running in 15ms.
- Difficulty: Easy
- Python
- Runtime 15ms
- Memory 23.7MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 15ms, memory 23.7MB, accepted 2025-12-30.
class Solution:
def numEquivDominoPairs(self, dominoes: List[List[int]]) -> int:
count = {}
result = 0
for a, b in dominoes:
key = (min(a, b), max(a, b))
if key in count:
result += count[key]
count[key] += 1
else:
count[key] = 1
return result