1128. Number of Equivalent Domino Pairs
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 61% Topics: Array, Hash Table, Counting
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(n)
import collections
class Solution(object):
def numEquivDominoPairs(self, dominoes):
"""
:type dominoes: List[List[int]]
:rtype: int
"""
counter = collections.Counter((min(x), max(x)) for x in dominoes)
return sum(v*(v-1)//2 for v in counter.itervalues())
Solution from kamyu104/LeetCode-Solutions · MIT