#1128
Number of Equivalent Domino Pairs
pupil · 400 · lc easy +24 · verified · 60.6% accepted · 1,117 likes · top 59%
Description
Two dominoes [a, b] and [c, d] are equivalent if a == c and b == d, or a == d and b == c (i.e., one can be rotated to match the other).
Given a list of dominoes, return the number of index pairs (i, j) with 0 <= i < j < dominoes.length where the two dominoes are equivalent.
Example 1:
Input: dominoes = [[1,2],[2,1],[3,4],[5,6]]
Output: 1
Example 2:
Input: dominoes = [[1,2],[1,2],[1,1],[1,2],[2,2]]
Output: 3
Code
1
2
3